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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 several calculations and group by date

Author  Topic 

e106199
Starting Member

13 Posts

Posted - 2006-01-13 : 10:31:43
hi all,
Here is what i m trying to accomplish:
i have a table with say 5 columns. each column keeps 0 or 1 or <null>. the last column is the date column.
user will select a start and end date and i will find the sum off all 1's that are in the interval for each column and group them by month. And the result will be the source of my grid.
here is a sample db schema:
col1 col2 col3 col4 coldate
----- ---- ---- ---- -------
<null> 1 1 1 1/2/2005
0 0 <null> 1 1/7/2005
1 1 <null> <null> 3/1/2005

if user selects 1/1/2005 as his start date and 3/2/2005 as his end date here is what i want him to see:
month totalcol1 totalcol2 totalcol3 totalcol4
----- --------- --------- --------- ---------
jan 05 0 1 1 2
feb 05 0 0 0 0
mar 05 1 1 0 0

this will show in my grid so i have to give grid such structure.
How can i make the calculations on sql side and create such structure for the grid?
thank you
-shane

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-01-13 : 10:44:19
I can give u some hints
-- Use ISNULL() to assign 0 when null
-- Check for DATENAME & Month in BOL
-- U have to do group by
-- Use between keyword in selection (where clause)
-- may need to write a function
Go to Top of Page
   

- Advertisement -