<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - Pomoc w napisaniu selecta]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=1422&amp;type=atom"/>
	<updated>2012-11-29T13:36:25Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=1422</id>
		<entry>
			<title type="html"><![CDATA[Odp: Pomoc w napisaniu selecta]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=3807#p3807"/>
			<content type="html"><![CDATA[można jeszcze tak, choć twój sposób jest bardzo dobry
select distinct x from tabela t where y=1 and exists (select 1 from tabela where x=t.x and y=2);
lub 
select distinct x from tabela t1 join tabela t2 on t1.x=t2.x and t2.y=2 where t1.y=1;

PS distinct dopisuje bo nie wiem czy zestaw danych x, y w tabeli jest unikatowy]]></content>
			<author>
				<name><![CDATA[c_michal]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=627</uri>
			</author>
			<updated>2012-11-29T13:36:25Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=3807#p3807</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: Pomoc w napisaniu selecta]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=3806#p3806"/>
			<content type="html"><![CDATA[Chyba tak:

select x from tabela where y = 1 intersect select x from tabela where y =2

i to nam da iksy, a jak mamy iksy to już wyciągniemy i całe wiersze.]]></content>
			<author>
				<name><![CDATA[tomek]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1459</uri>
			</author>
			<updated>2012-11-29T10:58:48Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=3806#p3806</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Pomoc w napisaniu selecta]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=3805#p3805"/>
			<content type="html"><![CDATA[Mam taką tabelę:

X | Y
------

3   | 1
3   | 2

5   | 1

8   | 2

12 | 1
12 | 1

55 | 2
55 | 2

64 | 1
64 | 1
64 | 2



Chciałbym wybrać tylko takie wiersze:

3   |1
3   |2
bo mam X = 3, a dla niego dwie różne wartości Y

64 | 1
64 | 1
64 | 2
bo mam X = 64, a dla nich dwie różne wartości Y,


ale nie chcę wybierać wierszy:

5   | 1

8   | 2

12 | 1
12 | 1

55 | 2
55 | 2

bo przykładowo mam X = 55, ale tylko jedną wartość Y=2.

------------------------------

Jakiego selecta mam napisać ?
Proszę o pomoc.]]></content>
			<author>
				<name><![CDATA[tomek]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1459</uri>
			</author>
			<updated>2012-11-29T09:10:06Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=3805#p3805</id>
		</entry>
</feed>
