<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - usuwanie / grupowanie powtarzających się wierszy postgresql 8.4]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=1471&amp;type=atom"/>
	<updated>2013-03-11T07:34:12Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=1471</id>
		<entry>
			<title type="html"><![CDATA[Odp: usuwanie / grupowanie powtarzających się wierszy postgresql 8.4]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4103#p4103"/>
			<content type="html"><![CDATA[Dzieki wielkie! Teraz działa pięknie!]]></content>
			<author>
				<name><![CDATA[carlos318i]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1553</uri>
			</author>
			<updated>2013-03-11T07:34:12Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4103#p4103</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: usuwanie / grupowanie powtarzających się wierszy postgresql 8.4]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4102#p4102"/>
			<content type="html"><![CDATA[Bo masz po jednym rekordzie z zadaną nazwą i datą, usuń z części select i group by pole ooo.add_date]]></content>
			<author>
				<name><![CDATA[c_michal]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=627</uri>
			</author>
			<updated>2013-03-11T07:30:19Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4102#p4102</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: usuwanie / grupowanie powtarzających się wierszy postgresql 8.4]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4101#p4101"/>
			<content type="html"><![CDATA[Ok. Teraz już nie ma błędu, ale nic mi nie sumuje. Wynik jest taki sam, jak po wywołaniu zapytania z 1 posta :(]]></content>
			<author>
				<name><![CDATA[carlos318i]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1553</uri>
			</author>
			<updated>2013-03-11T07:26:34Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4101#p4101</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: usuwanie / grupowanie powtarzających się wierszy postgresql 8.4]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4100#p4100"/>
			<content type="html"><![CDATA[Widzę że zmieniłeś swój post o 8:15, wcześniej załączyłeś inny select
teraz musisz zrobić analogicznie

SELECT 
    pp.plu AS "PLU",
    pp.name AS "NAZWA",
    bb.name AS "PROD.",
    sum(oo.amount) AS "ILOŚĆ",
    ooo.add_date AS "DATA"

FROM 
    products_product pp
    JOIN order_orderelement oo ON (pp.id = oo.product_id)
    JOIN order_order ooo ON (oo.order_id = ooo.id)
    JOIN brands_brand bb ON (pp.brand_id = bb.id)
WHERE 
    (ooo.add_date > '2013-01-01') AND (ooo.add_date < '2013-01-31')
group by 
    pp.plu, 
    pp.name,
    bb.name,
    ooo.add_date
ORDER BY pp.name;]]></content>
			<author>
				<name><![CDATA[c_michal]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=627</uri>
			</author>
			<updated>2013-03-11T07:24:06Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4100#p4100</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: usuwanie / grupowanie powtarzających się wierszy postgresql 8.4]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4099#p4099"/>
			<content type="html"><![CDATA[Niestety pojawia sie błąd:
[code]ERROR:  column "amount" must appear in the GROUP BY clause or be used in an aggregate function
LINE 3:  amount AS "ILOŚĆ"[/code]

Zaktualizowałem zapytanie w 1 poście. Wybieram w nim dane z kilku tabel. Może to powoduje błąd?]]></content>
			<author>
				<name><![CDATA[carlos318i]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1553</uri>
			</author>
			<updated>2013-03-11T07:05:53Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4099#p4099</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: usuwanie / grupowanie powtarzających się wierszy postgresql 8.4]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4098#p4098"/>
			<content type="html"><![CDATA[proszę

SELECT 
    name AS "NAZWA",
    sum(amount) AS "ILOŚĆ"
FROM 
    products_product
group by name
ORDER BY name;]]></content>
			<author>
				<name><![CDATA[c_michal]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=627</uri>
			</author>
			<updated>2013-03-11T06:57:04Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4098#p4098</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[usuwanie / grupowanie powtarzających się wierszy postgresql 8.4]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4097#p4097"/>
			<content type="html"><![CDATA[Witam. Wybieram sobie nazwę i ilość i potrzebuję usunać takie same wiersze, ale żeby ilość mi się sumowała. Widziałem kilka podobnych tematów, ale jakoś nie mogę tamtych rozwiązań zastosować do mojego zapytania.

[code]SELECT 
    pp.plu AS "PLU",
    pp.name AS "NAZWA",
    bb.name AS "PROD.",
    oo.amount AS "ILOŚĆ",
    ooo.add_date AS "DATA"

FROM 
    products_product pp
    JOIN order_orderelement oo ON (pp.id = oo.product_id)
    JOIN order_order ooo ON (oo.order_id = ooo.id)
    JOIN brands_brand bb ON (pp.brand_id = bb.id)
WHERE 
    (ooo.add_date > '2013-01-01') AND (ooo.add_date < '2013-01-31')

ORDER BY pp.name;[/code]

W wyniku takiego zapytania mam np:

[code]
PLU     NAZWA   PROD.   ILOŚĆ DATA
203     Banan    Dapan   0.350  2013-01-16
203     Banan    Dapan   0.400  2013-01-04
203     Banan    Dapan   0.500  2013-01-24
203     Banan    Dapan   0.600  2013-01-03
203     Banan    Dapan   2.000  2013-01-20
[/code]

NAZWA - character varying(128), ILOŚĆ - numeric (8,3)

I potrzebuję zrobić z tego 1 wiersz, ale żeby zsumowała mi się ilość, a z datą to nie wiem jak będzie prosciej - może się zachowywać tylko pierwsza, tj. abym w wyniku miał:

[code]
PLU     NAZWA   PROD.   ILOŚĆ DATA
203     Banan    Dapan   3.850  2013-01-16[/code]


Z góry dziękuję za pomoc]]></content>
			<author>
				<name><![CDATA[carlos318i]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1553</uri>
			</author>
			<updated>2013-03-11T06:08:44Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4097#p4097</id>
		</entry>
</feed>
