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.
| Author |
Topic |
|
miclare
Starting Member
5 Posts |
Posted - 2006-06-14 : 17:33:47
|
| in northwind database(orders table), i want to return shipvia values for different date intervals in one query.for example i want to return shipvia values for interval 01.08.1996 - 16.08.1996 and also for interval 16.09.1996 - 20.09.1996 in one query.this seems very easy at first but i think it's a lot tricky, i cldnt manage to do that. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-06-15 : 03:32:37
|
| Read about Cross-tab Reports in sql server help fileMadhivananFailing to plan is Planning to fail |
 |
|
|
miclare
Starting Member
5 Posts |
Posted - 2006-06-16 : 13:54:15
|
| i read about cross-tab reports, but this query gives error.SELECT SUM(CASE (SCANN.DATE BETWEEN @date1 AND @date2) WHEN 1 THEN SCANN.BMENG END) AS QSold, SUM(CASE SCANN.DATE BETWEEN DATEADD(YEAR, - 1, @date1) AND DATEADD(YEAR, - 1, @date2) WHEN 1 THEN SCANN.BMENG END) AS QSoldLastYearFROM...WHERE... |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-06-16 : 14:45:53
|
quote: Originally posted by miclare i read about cross-tab reports, but this query gives error.SELECT SUM(CASE (SCANN.DATE BETWEEN @date1 AND @date2) WHEN 1 THEN SCANN.BMENG END) AS QSold, SUM(CASE SCANN.DATE BETWEEN DATEADD(YEAR, - 1, @date1) AND DATEADD(YEAR, - 1, @date2) WHEN 1 THEN SCANN.BMENG END) AS QSoldLastYearFROM...WHERE...
The format of your case statement is invalid.casewhen condition1then value1when condition2then value2else value3endCODO ERGO SUM |
 |
|
|
miclare
Starting Member
5 Posts |
Posted - 2006-06-16 : 16:20:05
|
| thanks Michael Valentine, no syntax error when written as stored procedure, but microsoft reporting services gives an error "access violation or syntax error". any comment? |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-06-16 : 16:26:57
|
| If you have a stored procedure that is working, why not use that in Reporting Services?CODO ERGO SUM |
 |
|
|
|
|
|
|
|