SQL QUERY PROBLEM : ORDER BY POPULARITY THEN DISTINCT

  • Thread starter jonathan.cohen150887
  • Start date
J

jonathan.cohen150887

Hi,

I got the following query.

The thing is that I would like to order the results in order of
popularity and then distinct it so i dont have repeating results.
Problem is these two conflict each other so I dunno wot to do.Could
anyone help me correct this?

Thanks

SELECT Book_Stock.BS_TITLE, Genre.G_TYPE
FROM Book_Stock, Genre, Customer_Orders_Books
WHERE Book_Stock.BS_GENRE= Genre.GENRE_Ref
AND Book_Stock.ISBN_Ref = Customer_Orders_Books.ISBN_Ref
AND Genre.GENRE_Ref IN
(SELECT Genre.GENRE_Ref
FROM Book_Stock, Genre
WHERE Genre.GENRE_Ref = "01"
AND Book_Stock.BS_GENRE = Genre.GENRE_Ref)
GROUP BY Genre.G_TYPE, Book_Stock.BS_TITLE,
Customer_Orders_Books.CUSORDER_Ref
ORDER BY COUNT(Book_Stock.BS_TITLE) DESC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top