I have this book of order order, it has 2 columns, an order ID (primary key) and the other ID of the book that the customer ordered for example:
+ --------- + -------- + | Order id | Booked | + --------- + -------- + | 0001 | B002. | 0002 | B005 | | 0003 | B002. | 0004 | B3 3003 | 0005 | B005 | | 0006 | B002. | 0007 | B002. + --------- + -------- +
The book I want to obtain is the ID of the books which are 2 or more purchases / orders For example, if I run SQL queries against the above data, then I'll get it as a result:
+ -------- + | Booked | + -------- + | B002. | B005 | + -------- +
I do not know whether it can be stored in SQL or I have made a simple statement and repeat questions for all records In some other language I need to have some questions and thanks for reading my question.
Be sure this standard is SQL usable
syntax GROUP
and HAVING
statements:
SELECT BookId, your TableName from Ctr as COUNT (BookId) GROUP BY BookId Hosting (COUNTI) ) & Gt; = 2
Paste your real table name in place of YourTableName
in this query.
Select will return CNT
as SELECT BookId, COUNT (BookId):
+ ------ - + ----- + | Booked | CNT | + -------- + ----- + | B002. 4 | | B005 | 2 | + -------- + ----- +
Comments
Post a Comment