Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi all, i am prity new to sql and am just learning (that hard way)I have this code and i am trying to get out of it: a date with the number of calles that have been taken on that date between 2 dates.SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTEDDECLARE @DisplayFrom as DATETIMEDECLARE @DisplayTo as DATETIMEDECLARE @FromDate as DATETIMEDECLARE @ToDate as DATETIMESET @DisplayFrom = <%FromDate|Enter start date%>SET @DisplayTo = <%ToDate|Enter end date%>SET @FromDate = dbo.fUniversalTime(@DisplayFrom)SET @ToDate = dbo.fUniversalTime(@DisplayTo)SELECT SUM(ActiveDate), ActiveDateFROM(SELECT DISTINCT (ActiveDate) from [case])as T where ActiveDate between @FromDate and @ToDategroup by ActiveDatee.g. output01/02/07 5202/02/07 63etc...hope this makes senceNeil
snSQL
Master Smack Fu Yak Hacker
1837 Posts
Posted - 2007-03-05 : 13:05:18
Are you using SQL Server? If not then this probably won't work, but your query should be something like:
SELECT convert(varchar(10), ActiveDate, 3), count(*)FROM [case]where ActiveDate between @FromDate and @ToDategroup by convert(varchar(10), ActiveDate, 3)