i want to select only one row per user and date
so if the data like this
ID User Date
25 3597 2014-09-04 13:37:12.953
26 2100 2014-09-04 13:37:29.820
27 3597 2014-09-04 13:38:12.953
28 2100 2014-09-04 13:38:29.820
29 3597 2014-09-05 13:40:12.953
30 2100 2014-09-05 13:40:29.820
the result should be 4
The result should be
4
If all you need is the count, in SQL, you can use COUNT(DISTINCT)
, like this:
SELECT COUNT(DISTINCT User, Date) FROM MyTable
In LINQ, you can use GroupBy
followed by Count
:
int cnt = src.Items.GroupBy(item => new {i.User, i.Date}).Count();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.