Hi,
I have to implement charts in my application. Suppose i have a table structure
DECLARE @SONGS TABLE
(
[ID] INT IDENTITY,
[SONGNAME] VARCHAR(20),
[CREATEDDATE] DATETIME
)
INSERT INTO @SONGS
SELECT 'SONG1','20091102' UNION ALL
SELECT 'SONG2','20091103' UNION ALL
SELECT 'SONG3','20091107' UNION ALL
SELECT 'SONG4','20091107' UNION ALL
SELECT 'SONG5','20091107' UNION ALL
SELECT 'SONG6','20091109'
Now user will pass start date and end date from outside as parameters like below
DECLARE @STARTDATE DATETIME
DECLARE @ENDDATE DATETIME
SET @STARTDATE='20091101'
SET @ENDDATE='20091111'
Now user has further one more option(SAY @OPTION VARCHAR(20) ) whether he wants the results with dates split into individual dates between the start date and end date, second option he can choose to have the results with dates into the months between the start date and end date, similarly for year.
--OUTPUT I NEED IS when @OPTION IS DATE
DATE [SONGCOUNT]
------------------------------------------
20091101 0
20091102 1
20091103 1
20091104 0
20091105 0
20091106 0
20091107 3
20091108 0
20091109 1
20091110 0
20091111 0
Similarly i want the results with dates splitted according the option(day,week,month,year) having count next to it. My goal is to display date on xaxis and count on y axis, can you suggest me a way to implement the same.