开发者

TSQL Howto get count of unique users?

开发者 https://www.devze.com 2023-01-04 00:13 出处:网络
This is really dumb question but still my head cannot work it out. I have a table with Orders, each o开发者_JS百科rder has userID in it. User can have unlimited amount of Orders. How do i make count o

This is really dumb question but still my head cannot work it out. I have a table with Orders, each o开发者_JS百科rder has userID in it. User can have unlimited amount of Orders. How do i make count of unique userIDs ?


You can;

SELECT COUNT(DISTINCT userID) 
FROM Tbl

You can give the count column a name by aliasing it:

SELECT COUNT(DISTINCT userID)  NumberOfDistinctUsers
FROM Tbl


select count(*) from
(select distinct userid form ordertable) d
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号