Results 1 to 2 of 2

Thread: [RESOLVED] sql server 2000 - eliminate duplicate rows of aggregate columns

  1. #1

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,566

    Resolved [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.

  2. #2

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,566

    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 !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width