Distinct Records

  • I have one table

    table Product

    sku varchar 5,

    name varchar 500,

    productsize varchar 25,

    productcolor varchar 25,

    productwidth varchar25

    i need to retrieve distinct size ,distinct color, and distinct width . i prefer to use one stored proc. is the only way with 3 different queries? thanks


    </cm>

  • Do you want these in separate columns? IF so, this doesn't make sense unless it is the distinct (size, color, width)

    select distinct productsize, productcolor, productwidth

    will give you this. If you want them in the same column, but separate items, you could do

    select distinct

    productsize, 'size'

    union

    select distinct

    productcolor, 'color'

    ...

    This will put the results in one recordset.

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply