removing doubles from results - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

removing doubles from results

anniedannied Posts: 1Member
I have a sql question relating to a music store's database that reads

"List the product name, artist and price of all items that are only available in CD format, not 12 inch record"

There are doubles that occur because they are avail on both cd an 12". i need to somehow write a query to just select the songs that are only avail on cd. How do i do it??.

'format' is the column for cd or 12'. i have no control over how the database is configured. the column is 'format', and the value is either 'cd' or '12'. i cant change that

i dont know how to compare the rows.

Comments

  • JonathanJonathan Posts: 2,914Member
    : I have a sql question relating to a music store's database that reads
    :
    : "List the product name, artist and price of all items that are only available in CD format, not 12 inch record"
    :
    : There are doubles that occur because they are avail on both cd an 12". i need to somehow write a query to just select the songs that are only avail on cd. How do i do it??.
    :
    : 'format' is the column for cd or 12'. i have no control over how the database is configured. the column is 'format', and the value is either 'cd' or '12'. i cant change that
    :
    : i dont know how to compare the rows.

    Hi,

    Could you do something like:-

    SELECT artist, title, label, price
    FROM stock
    WHERE format = 'CD' AND COUNT(*) >= 2
    GROUP BY artist, title, label

    Jonathan



    ###
    # Example Of Perl 6 Syntax.
    push @will, my Power $button;
    my $hardware is Useless but Valuable;
    do ($nothing) while $i.work and print $stuff;
    push (@will, my Off $button) and die "with me";

Sign In or Register to comment.