<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - Suma wyniku w kolumnie]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=2169&amp;type=atom"/>
	<updated>2014-06-18T09:58:26Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=2169</id>
		<entry>
			<title type="html"><![CDATA[Odp: Suma wyniku w kolumnie]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=5268#p5268"/>
			<content type="html"><![CDATA[[code]select *, sum(kwota) over (partition by miesiac)
from tabela
order by id;[/code]

albo

[code]select a.*, (select sum(b.kwota) from tabela b where b.miesiac = a.miesiac)
from tabela a
order by a.id;[/code]

albo

[code]select a.*, b.suma
from tabela a
    join (select miesiac, sum(kwota) as suma from tabela group by miesiac) b using (miesiac)
order by id;[/code]]]></content>
			<author>
				<name><![CDATA[depesz]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1564</uri>
			</author>
			<updated>2014-06-18T09:58:26Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=5268#p5268</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Suma wyniku w kolumnie]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=5267#p5267"/>
			<content type="html"><![CDATA[Witam,

Mam tabelę

która ma kolumny

id, kwota, miesiac

w tabeli mam  dane

1, 100, Styczen
2, 50, Styczen
3, 40, Luty
4, 20, Marzec
5, 30, Marzec

Nie mogę poradzić sobie z zapytanie, które pokaże mi na wyniku to samo co powyżej ale z dodatkową kolumną która będzie sumą kwoty w danym miesiącu.

Czyli

1, 100, Styczen, 150
2, 50, Styczen, 150
3, 40, Luty, 40
4, 20, Marzec, 50
5, 30, Marzec, 50

Proszę o pomoc :)]]></content>
			<author>
				<name><![CDATA[milocha]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1955</uri>
			</author>
			<updated>2014-06-18T07:58:03Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=5267#p5267</id>
		</entry>
</feed>
