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 |
joefor
Starting Member
2 Posts |
Posted - 2013-06-24 : 13:35:27
|
Can anyone help with the below?Select Name AS name, SUM(people) AS FORECAST,CASE NameWHEN 'Joe' THEN 'Joe'WHEN 'Kevin' THEN 'Kevin'ELSE 'UNKNOWN'END "Last Name",FROM table_nameWHERE Date <= '2012'ORDER BY name, people; |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-06-24 : 13:37:23
|
[code]Select Name AS name, SUM(people) AS FORECAST,CASE NameWHEN 'Joe' THEN 'Joe'WHEN 'Kevin' THEN 'Kevin'ELSE 'UNKNOWN'END "Last Name"FROM table_nameWHERE Date <= '2012'GROUP BY Name,CASE NameWHEN 'Joe' THEN 'Joe'WHEN 'Kevin' THEN 'Kevin'ELSE 'UNKNOWN'END ORDER BY name,FORECAST[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
joefor
Starting Member
2 Posts |
Posted - 2013-06-24 : 13:47:56
|
quote: Originally posted by visakh16
Select Name AS name, SUM(people) AS FORECAST,CASE NameWHEN 'Joe' THEN 'Joe'WHEN 'Kevin' THEN 'Kevin'ELSE 'UNKNOWN'END "Last Name"FROM table_nameWHERE Date <= '2012'GROUP BY Name,CASE NameWHEN 'Joe' THEN 'Joe'WHEN 'Kevin' THEN 'Kevin'ELSE 'UNKNOWN'END ORDER BY name,FORECAST ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs
Made a change but still getting an error, see below:Select FAB_PROCESS AS PROCESS, SUM(start_req_qty) AS FORECASTCASE FAB_PROCESSWHEN 'S18' THEN 'S18'WHEN 'S4' THEN 'S4'ELSE 'UNKNOWN'END "FAB_PROCESS"FROM Waf_Start_RqmntWHERE Date <= '2014_01'GROUP BY FAB_PROCESS,CASE FAB_PROCESSWHEN 'S18' THEN 'S18'WHEN 'S4' THEN 'S4'ELSE 'UNKNOWN'END ORDER BY FAB_PROCESS,FORECAST; |
|
|
MuMu88
Aged Yak Warrior
549 Posts |
Posted - 2013-06-24 : 14:02:11
|
Try this with the following edits:quote: Originally posted by joefor Made a change but still getting an error, see below:Select FAB_PROCESS AS PROCESS, SUM(start_req_qty) AS FORECAST, -- MISSING ','CASE FAB_PROCESSWHEN 'S18' THEN 'S18'WHEN 'S4' THEN 'S4'ELSE 'UNKNOWN'END "FAB_PROCESS"FROM Waf_Start_RqmntWHERE Date <= '2014-01-01'GROUP BY FAB_PROCESS,CASE FAB_PROCESSWHEN 'S18' THEN 'S18'WHEN 'S4' THEN 'S4'ELSE 'UNKNOWN'END ORDER BY FAB_PROCESS,FORECAST;
|
|
|
|
|
|
|
|