Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report per Month - summation

Status
Not open for further replies.

net123

Programmer
Oct 18, 2002
167
0
0
US
I have a datagrid that displays results of some metrics from a SQL Server 2000 database grouped by Date. When a user first enters the site, there are two textfields for entry of two dates: date1 and date2. And as you guessed it, the results are shown between these two dates.

I would like create a similar report that displays all of the data (sums) for the current month. How can I do this? I have tried, but can't seem to get it correctly.

Here is my original SQL SELECT statement:

Dim queryString As String = "SELECT Convert(char(10),DataDate,101) as [Date], SUM([Data1]), SUM([Data2]), SUM([Data3]" & _
"FROM [tblData] WHERE ([DataDate] BETWEEN @Search AND @Search2) GROUP BY [DataDate]"

Is there someway to select per DataDate.Now.Month or so?
 
If you copied and pasted that, I see a typo. You are saying GROUP BY [DataDate] but you said SELECT ... As [Date]
 
No, there is no typo. That is just the column heading (Date) as opposed to leaving it (DateDate).

 
You probably already have the answer to this but you needed to group by Convert(char(10),DataDate,101) not just datadate because your time will make the records unique
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top