Answer the question
In order to leave comments, you need to log in
SQL Counting Unique Values?
There is a table orders:
id|user_id
in this table all orders of all users
how to calculate how many unique users user_id in this table?
there is no separate users table, so it is not possible to calculate normally
Answer the question
In order to leave comments, you need to log in
The query above will return a list of unique values
This query will return the countSELECT COUNT(DISTINCT user_id) FROM orders
Gentlemen, you must be joking.
SELECT userId,COUNT(userId)
FROM orders
GROUP BY userId
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question