sql server - TSQL: How to get distinct values over a period of time but not within my group by -


I'm not sure the title is correct, but what am I trying to do, prepare a composite table with figures Has been done from hour , but I do not need different values ​​for a period of time, not until that time. Example:

  Date of ID Group ------------------------- 1 1 1/1/2014 11: 00 2 1 1/1/2014 11:00 1 1 1/1/2014 11:00 3 1 1/1/2014 11:00 3 2 1/1/2014 12:00 1 2 1/1/2014 12: 00 1 1 1/1/2014 12:00 2 1 1/1/2014 12:00 4 1 1/1/2014 12:00   

The result will be: Calculation group hours ------------------------ 3 1 11:00 2 2 12:00 1 1 12:00

Notice how many times the ID of 1 is displayed within group 1, but only counted once in one hour, but is grouped for one hour. My problem is that I get unique with that time, but if one more hour is counted in the second hour

this is my query:

  Merge dbo.tblStatsHourlyDomainCampaign Use the target as (select (left (conversion (VARCHAR, sl.CreateDate, 120), 13) + ': 00') as the report date, M. domaine, COUNT (separate slim EEMID) Opens in, the CL. Quinine FD Deborah TLEML in inner join deobo.TBI impressionog SOL on M.EEA MIID = SLE Email Email WHERE SL.CreateDate> = '10/1/2014' and SL. Credit & amp; LT; 10/10/2014 'On the Left Side (Convert (VAcarar, SL Cutte, 120), 13 ) + ': 00', AM DOMINID, SL.QVID) at source (target.domainid = source.domainID and targetRivordada = source report day and target.cuid = source.quinid) when target and source do not match is done. Dominate is not (domain ID, report-date, opens, QIID) value (source. Domainad, source report, source ops, source.quinid) when the update set target was determined. Opense = source. Opens; Selection Number (1), [Group], Artist (Group)   

< / pre>

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -