We have a table like this:
+ ---- + - ------- + | ID | Item ID | + ---- + -------- + | 1 | 1100 | | 1 | 1101 | | 1 | 1102 | | 2 | 2001. | 2 | 2002. | 3 | 1101 | + ---- + -------- + We want to count how many people are, and show them with 2 objects or more. Like this:
+ ---- + ----------- + | ID | Madcount | + ---- + ----------- + | 1 | 3 | | 2 | 2 | + ---- + ----------- + We did not count that person with ID = 3 because he only got 1 item.
How can we do this in SQL?
SELECT id, COUNT (item id) AS item number with item ID from your item (Item ID) & gt; 1
No comments:
Post a Comment