SajjadZare SajjadZare - 2 months ago 7
SQL Question

Write query for this example

I have a table with below data,I want to write a query that give me id and the number of days that have connection.

For example for id 1 give me 2 times (2016-09-20 , 2016-09-22)

enter image description here

Answer
SELECT id, COUNT(DISTINCT convert(date, startTime)) as noOfDays
FROM your_table
GROUP BY id
Comments