noob
noob

Reputation: 3

Counting records by user

I'm new to SQL (AIX) and I can't find exactly what I'm looking for. I'd like to find out how many orders are keyed in by each user:

so-order-no   user-id
1234          John
2345          John
4567          Bill
7890          Bill
3455          Bill
2144          Fred

Upvotes: 0

Views: 56

Answers (1)

Steve
Steve

Reputation: 216293

A simple COUNT and GROUP BY

SELECT user-id, count(so-order-no) AS TotalOrders
FROM ordertable
GROUP BY user-id

Note, I don't know the table name so I have called generically ordertable. Substitute with your real table name

GROUP BY
COUNT

Upvotes: 1

Related Questions