counts per day

0

Please login or register to vote for this query.

(click on this box to dismiss)

demo for Multiple Counts from the same row with range

Drupal Answers Meta

Q&A about the site for Drupal developers and administrators

-- counts per day
-- demo for Multiple Counts from the same row with range


declare @trans table (operationId int primary key, dt datetime)
insert INTO @trans
values (1,'2011-11-11 10:00'),(2,'2011-11-11 11:00')

SELECT COUNT(*) AS trans
,count(CASE WHEN cast(dt As date) = '2011-11-11' THEN 1 ELSE NULL END) AS day11
,count(CASE WHEN cast(dt As date) = '2011-11-12' THEN 1 ELSE NULL END) AS day12
  FROM @trans 
--  WHERE hitTime BETWEEN '2011-10-14 00:00:00' AND '2011-10-14 23:59:59.99'
--  group by 1;

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results