Hi comunidadmexi...,
Refer below query.
SQL
DECLARE @LOG AS TABLE
(
[id] bigint IDENTITY(1,1) NOT NULL,
[user] nvarchar(10) NULL,
[PageView] nvarchar(100) NULL,
[DateHour] smalldatetime DEFAULT getdate() NULL
)
INSERT INTO @LOG VALUES('97697','APP 1','12/18/2017 18:12:00')
INSERT INTO @LOG VALUES('97697','APP 1','12/18/2017 18:15:00')
INSERT INTO @LOG VALUES('15841','APP 1','12/18/2017 18:31:00')
INSERT INTO @LOG VALUES('15841','APP 1','12/18/2017 18:53:00')
INSERT INTO @LOG VALUES('15841','APP 1','12/18/2017 19:04:00')
INSERT INTO @LOG VALUES('15841','APP 1','12/18/2017 19:09:00')
INSERT INTO @LOG VALUES('09623','APP 1','12/18/2017 20:15:00')
INSERT INTO @LOG VALUES('23265','APP 1','12/18/2017 21:05:00')
INSERT INTO @LOG VALUES('09623','APP 1','12/18/2017 21:29:00')
INSERT INTO @LOG VALUES('25506','APP 1','12/18/2017 21:49:00')
INSERT INTO @LOG VALUES('20986','APP 1','12/18/2017 22:33:00')
INSERT INTO @LOG VALUES('25623','APP 1','12/18/2017 23:46:00')
INSERT INTO @LOG VALUES('95932','APP 1','12/19/2017 00:02:00')
INSERT INTO @LOG VALUES('29067','APP 1','12/19/2017 00:03:00')
INSERT INTO @LOG VALUES('32337','APP 1','12/19/2017 00:09:00')
INSERT INTO @LOG VALUES('23265','APP 1','12/19/2017 00:16:00')
INSERT INTO @LOG VALUES('09343','APP 1','12/19/2017 00:20:00')
INSERT INTO @LOG VALUES('20901','APP 1','12/19/2017 00:35:00')
INSERT INTO @LOG VALUES('26786','APP 1','12/19/2017 00:47:00')
INSERT INTO @LOG VALUES('24980','APP 1','12/19/2017 00:49:00')
INSERT INTO @LOG VALUES('25996','APP 1','12/19/2017 00:52:00')
INSERT INTO @LOG VALUES('14949','APP 1','12/19/2017 01:03:00')
INSERT INTO @LOG VALUES('54987','APP 1','12/19/2017 01:47:00')
INSERT INTO @LOG VALUES('23265','APP 1','12/19/2017 04:53:00')
INSERT INTO @LOG VALUES('97697','APP 2','12/18/2017 18:15:00')
INSERT INTO @LOG VALUES('97697','APP 2','12/18/2017 18:18:00')
INSERT INTO @LOG VALUES('97697','APP 2','12/18/2017 18:25:00')
INSERT INTO @LOG VALUES('15841','APP 2','12/18/2017 19:10:00')
INSERT INTO @LOG VALUES('20635','APP 3','12/19/2017 06:14:00')
INSERT INTO @LOG VALUES('25081','APP 3','12/19/2017 06:38:00')
INSERT INTO @LOG VALUES('61660','APP 3','12/19/2017 06:42:00')
SELECT DISTINCT [PageView],(SELECT COUNT(*)/(SELECT COUNT(DISTINCT CONVERT(VARCHAR(10), DateHour, 111)) FROM @LOG) FROM @LOG l2 WHERE l1.PageView=l2.PageView) [Count]
FROM @LOG l1
GROUP BY PageView,CONVERT(VARCHAR(10), DateHour, 111)
Output
PageView Count
APP 1 12
APP 2 2
APP 3 1