[RESOLVED] sql server 2000 - eliminate duplicate rows of aggregate columns
I am running this query:
SELECT nm, abbr, ldc_ik FROM pipeline_ldc
JOIN ldc ON ldc.abbr = pipeline_ldc.ldc_abbr
and am getting:
Atlanta Gas Light Company AGL 2
Atlanta Gas Light Company AGL 2
Atlanta Gas Light Company AGL 2
Atlanta Gas Light Company AGL 2
Bay State Gas Company BSGC 4
Bay State Gas Company BSGC 4
Bay State Gas Company BSGC 4
I want to eliminate rows 2, 3, 5 and 6 so I have unqiue rows, but I don't know how to do it when my select gets three columns (ie. distinct only works on one column). Can you offer a solution?
Thanks.
Re: sql server 2000 - eliminate duplicate rows of aggregate columns
I'm sorry. I actually had a typo the first time I tried it and I thought it was a syntax error not letting me do what I wanted to do. This worked:
SELECT distinct nm, abbr, ldc_ik FROM pipeline_ldc
JOIN ldc ON ldc.abbr = pipeline_ldc.ldc_abbr order by ldc.abbr
This did not work:
SELECT distinct (nm, abbr, ldc_ik) FROM pipeline_ldc
JOIN ldc ON ldc.abbr = pipeline_ldc.ldc_abbr order by ldc.abbr
It gave me an error on the comma, so I thought I couldn't list columns.
Thanks anyway :o !