I have a table called logvisit with fields including ip (varchar(30)) and date (datetime) :
ip date
1.1 2016-08-23 00:05:40
1.1 2016-08-24 00:05:15
1.1 2016-08-24 00:05:20
1.2 2016-08-22 00:01:00
1.2 2016-08-22 00:00:30
1.2 2016-08-23 00:01:00
EDIT : I want to SELECT all distinct ip by DAY. One IP can have several days (if the user comes three days in a row), and one day can have several IP (because I have more than one user). I just don't want the same IP on the same day.
Expected output (1 ip / 1 day) :
ip day
1.1 2016-08-23
1.1 2016-08-24
1.2 2016-08-22
1.2 2016-08-23
I found this thread SQL group by day, with count so as a beginning I tried :
SELECT
Convert(char(8), date, 112),
count(distinct ip)
FROM logvisit
GROUP BY Convert(char(8), date, 112)
which gave me an unexpected "Syntax error near 112), count(distinct ip"..