<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - działania na rekordach z dwóch tabel]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=1939&amp;type=atom"/>
	<updated>2014-02-25T23:31:00Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=1939</id>
		<entry>
			<title type="html"><![CDATA[Odp: działania na rekordach z dwóch tabel]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4995#p4995"/>
			<content type="html"><![CDATA[wielkie dzięki zadziałało]]></content>
			<author>
				<name><![CDATA[sylwek]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1727</uri>
			</author>
			<updated>2014-02-25T23:31:00Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4995#p4995</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: działania na rekordach z dwóch tabel]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4993#p4993"/>
			<content type="html"><![CDATA[Nie testowałem, ale powinno zadziałać:

[code]
select
    coalesce(e.goodid, r.goodid) as goodid,
    coalesce(r.count_remanent, 0) - coalesce(e.count_in_emporium, 0) as result
from
    tabela1 e
    full outer join
    tabela2 r using (goodid)
[/code]]]></content>
			<author>
				<name><![CDATA[depesz]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1564</uri>
			</author>
			<updated>2014-02-23T10:57:21Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4993#p4993</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[działania na rekordach z dwóch tabel]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4992#p4992"/>
			<content type="html"><![CDATA[Czy ktoś może pomóc rozwiązać nastœpujący problem z  zapytaniem?

tabela1
 goodid | count_in_emporium 
--------+-------------------
      0 |            157.00
      1 |           -170.00
      2 |            -36.00
      3 |            -99.00
      4 |            -10.00
      7 |            -12.00
     12 |              3.00
     13 |            -15.00
     16 |             12.00
(9 rows)
tabela2
 goodid | count_remanent  
--------+-------
      1 | 10.00
      7 | 12.00
     13 |  9.00
(3 rows)

Jak zadać pytanie gdzie wynikiem bedzie tabela o dwóch kolumnach:

goodid | count_remanent - count_in_emporium
-------+-----------------------------------
     0 |  157.00
     1 |  180.00
     2 |   36.00
     3 |   99.00
     4 |   10.00
     7 |   24.00
    12 |   -3.00
    13 |   24.00
    16 |  -12.00


w drugiej kolumnie jest wynik odejmowania wartości kolumn z dwóch tabel przy zachowaniu warunku równości pola goodid z tabeli 1 i 2,  ale jeżeli w jednej z tabel nie ma zadanej wartości goodid to pole count_(coś tam dalej) ma wartośc zero]]></content>
			<author>
				<name><![CDATA[sylwek]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1727</uri>
			</author>
			<updated>2014-02-22T17:46:28Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4992#p4992</id>
		</entry>
</feed>
