Weedpacket;11035657 wrote:I think [font=monospace]SELECT DISTINCT ON (identifier) identifier, fld1, fld2, ... FROM the_table[/font] would be PostgreSQL's approach. The expression(s) in font=monospace[/font] is/are the criteria used to determine if a row is "distinct", while the following expressions are the columns actually returned.
We may have a winner!
select distinct on (identifier) identifier, fld1, fld2, fld3, fld4, fld5
from fubar.the_table
order by identifier
limit 30
"identifier","fld1","fld2","fld3","fld4_almost_always_empty","fld5"
"10000112","834","ANTH","000000780352","","01"
"10000141","834","ANTH","000000780421","","01"
"10000236","834","ANTH","000000780612","","01"
"10000238","834","ANTH","000000780614","","01"
"10000303","834","ANTH","000000780793","","01"
"10000801","803","NY1B","135JP1","","01"
"10000805","834","ANTH","000000781636","","01"
"10000806","834","ANTH","000000781637","","01"
"10000807","834","ANTH","000000781638","","01"
"10001003","834","ANTH","000000782035","","01"
"10001089","530","AZL2","79892","","05"
"10001091","834","OHF2","000000782287","","01"
"10001095","834","OHF1","000000782296","","01"
"10001310","834","OHF2","000000782988","","01"
"10001312","834","ANTH","000000782998","","01"
"10001317","834","ANTH","000000783007","","01"
"10001321","834","ANTH","000000507501","","01"
"10001924","834","ANTH","000000784439","","01"
"10001979","834","ANTH","000000784449","","01"
"10002784","834","OHF1","310950892990","","01"
"10003643","834","OHL5","000000706247","","01"
"10003786","834","ANTH","000000788508","","01"
"10007388","834","ANTH","000000795577","","01"
"10012466","134","OHF1","3110113791","","01"
"10012468","134","OHF1","0105546521","","01"
"10012472","834","OHF1","0105925821","","01"
"10012479","834","OHF1","010801599001","","01"
"10012481","134","OHF1","0108015991","","01"
"10012482","134","OHF1","3417242241","","01"
"10012485","134","OHF1","0166003024","","01"