dbTalk Databases Forums  

Re: Subquery problems

comp.databases.postgresql comp.databases.postgresql


Discuss Re: Subquery problems in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #21  
Old   
Andreas Kretschmer
 
Posts: n/a

Default Re: Subquery problems - 10-28-2008 , 02:52 AM






begin Coniglio Sgabbiato schrieb:
Quote:
Another option is to use DISTINCT ON, so something like

SELECT DISTINCT ON (Fld1) Fld3 FROM table ORDER BY Fld1, Fld2 DESC;

But it's rather ugly. As usual, test with your own data to see how its
performance compares with other approaches.

I did not know this clause, good to know, it could be really useful.
Keep in mind, it is a postgresq-extension, not per SQL-spec.



end
Andreas
--
Andreas Kretschmer
Linux - weil ich es mir wert bin!
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net


Reply With Quote
  #22  
Old   
Andreas Kretschmer
 
Posts: n/a

Default Re: Subquery problems - 10-28-2008 , 02:52 AM






begin Coniglio Sgabbiato schrieb:
Quote:
Another option is to use DISTINCT ON, so something like

SELECT DISTINCT ON (Fld1) Fld3 FROM table ORDER BY Fld1, Fld2 DESC;

But it's rather ugly. As usual, test with your own data to see how its
performance compares with other approaches.

I did not know this clause, good to know, it could be really useful.
Keep in mind, it is a postgresq-extension, not per SQL-spec.



end
Andreas
--
Andreas Kretschmer
Linux - weil ich es mir wert bin!
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net


Reply With Quote
  #23  
Old   
Andreas Kretschmer
 
Posts: n/a

Default Re: Subquery problems - 10-28-2008 , 02:52 AM



begin Coniglio Sgabbiato schrieb:
Quote:
Another option is to use DISTINCT ON, so something like

SELECT DISTINCT ON (Fld1) Fld3 FROM table ORDER BY Fld1, Fld2 DESC;

But it's rather ugly. As usual, test with your own data to see how its
performance compares with other approaches.

I did not know this clause, good to know, it could be really useful.
Keep in mind, it is a postgresq-extension, not per SQL-spec.



end
Andreas
--
Andreas Kretschmer
Linux - weil ich es mir wert bin!
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.