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 |
|
lingtrin
Starting Member
13 Posts |
Posted - 2008-08-06 : 16:51:11
|
| Hi all, I have an statement:SELECT TOP 100 PERCENT ITEMNMBR, trxloctn, SUM(CASE WHEN datediff(month, docdate, getdate()) = 0 THEN TRXQTY ELSE 0 END) AS period1, SUM(CASE WHEN datediff(month, docdate, getdate()) = 1 THEN TRXQTY ELSE 0 END) AS period2, SUM(CASE WHEN datediff(month, docdate, getdate()) = 2 THEN TRXQTY ELSE 0 END) AS period3, SUM(CASE WHEN datediff(month, docdate, getdate()) = 3 THEN TRXQTY ELSE 0 END) AS period4, SUM(CASE WHEN datediff(month, docdate, getdate()) = 4 THEN TRXQTY ELSE 0 END) AS period5, SUM(CASE WHEN datediff(month, docdate, getdate()) = 5 THEN TRXQTY ELSE 0 END) AS period6, SUM(CASE WHEN datediff(month, docdate, getdate()) IN (0, 1, 2, 3, 4, 5) THEN TRXQTY ELSE 0 END) / 6 * - 1 AS totalFROM dbo.IV30300WHERE trxloctn = 'mp' AND TRXQTY < 0GROUP BY ITEMNMBR, trxloctnI wangt to change the "where" clause to something like:WHERE trxloctn in ('mp', 'TRANSIT-01', 'HARNESS') AND TRXQTY < 0But I get an arror that is not allowed, how can I do this?Thanks in advance for your soonest reply |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2008-08-06 : 16:59:26
|
| What is the exact error message? I have no trouble parsing that statement with the WHERE clause you requested.e4 d5 xd5 Nf6 |
 |
|
|
lingtrin
Starting Member
13 Posts |
Posted - 2008-08-06 : 17:03:41
|
| This is the error message:The Query Designer does not support the CASE SQL construct.If I leave it like the one on top, it works great |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2008-08-06 : 17:20:26
|
don't use the query designer? also take the TOP 100 PERCENT out. it serves no purpose. elsasoft.org |
 |
|
|
lingtrin
Starting Member
13 Posts |
Posted - 2008-08-06 : 17:29:19
|
| I did it on query analizer and it worked, so query designer doesn't work? |
 |
|
|
lingtrin
Starting Member
13 Posts |
Posted - 2008-08-06 : 18:01:05
|
| Thanks y'all! |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2008-08-06 : 19:13:01
|
as the error message stated: "The Query Designer does not support the CASE SQL construct." elsasoft.org |
 |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2008-08-06 : 20:08:34
|
| Query designer cannot graphically display the query.e4 d5 xd5 Nf6 |
 |
|
|
|
|
|
|
|