Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Postgresql doesn't accept DISTINCTROW

Status
Not open for further replies.

FBELGHAIT

Programmer
Mar 22, 2002
10
0
0
US
Hi every body,

I need to use DISTINCTROW in my sql statement, but the parser of postgres doesn't accept it. the following sql statement doesn't work on postgres

SELECT DISTINCTROW field1,field2 FROM TABLE

when i replace "distinctrow" with "distinct" it works.

if somebody has an idea i'll be very thankful

fbelghait
 
I am not familiar with DISTINCTROW, but let me guess: It makes sure that it only returns distinct rows, using all fields of the table, even if you haven't specified the fields in the query. If that is the case, then simply specify all the fields with a regular DISTINCT query, and you will have distinct rows. Or just do "DISTINCT * FROM"

I know this might return more columns than you need, but too much is better than not enough ;-). If it's ciritical, there's probably a way to suppress output of some columns somehow, if you do some sort of clever use of self-join, or perhaps the CASE operator.

In clarification:

DISTINCT will return distinct rows using the combination of all columns you specify in your query.

DISTINCT ON {fieldname} will only use the specified field as its criteria, rather than all fields combined.

See -------------------------------------------

"Calculus is just the meaningless manipulation of higher symbols"
                          -unknown F student
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top