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
 General SQL Server Forums
 New to SQL Server Programming
 SQL Error

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 Name
WHEN 'Joe' THEN 'Joe'
WHEN 'Kevin' THEN 'Kevin'
ELSE 'UNKNOWN'
END
"Last Name",
FROM table_name
WHERE 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 Name
WHEN 'Joe' THEN 'Joe'
WHEN 'Kevin' THEN 'Kevin'
ELSE 'UNKNOWN'
END
"Last Name"
FROM table_name
WHERE Date <= '2012'
GROUP BY Name,CASE Name
WHEN 'Joe' THEN 'Joe'
WHEN 'Kevin' THEN 'Kevin'
ELSE 'UNKNOWN'
END
ORDER BY name,FORECAST
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

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 Name
WHEN 'Joe' THEN 'Joe'
WHEN 'Kevin' THEN 'Kevin'
ELSE 'UNKNOWN'
END
"Last Name"
FROM table_name
WHERE Date <= '2012'
GROUP BY Name,CASE Name
WHEN 'Joe' THEN 'Joe'
WHEN 'Kevin' THEN 'Kevin'
ELSE 'UNKNOWN'
END
ORDER BY name,FORECAST


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://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 FORECAST
CASE FAB_PROCESS
WHEN 'S18' THEN 'S18'
WHEN 'S4' THEN 'S4'
ELSE 'UNKNOWN'
END
"FAB_PROCESS"
FROM Waf_Start_Rqmnt
WHERE Date <= '2014_01'
GROUP BY FAB_PROCESS,CASE FAB_PROCESS
WHEN 'S18' THEN 'S18'
WHEN 'S4' THEN 'S4'
ELSE 'UNKNOWN'
END
ORDER BY FAB_PROCESS,FORECAST;
Go to Top of Page

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_PROCESS
WHEN 'S18' THEN 'S18'
WHEN 'S4' THEN 'S4'
ELSE 'UNKNOWN'
END
"FAB_PROCESS"
FROM Waf_Start_Rqmnt
WHERE Date <= '2014-01-01'
GROUP BY FAB_PROCESS,CASE FAB_PROCESS
WHEN 'S18' THEN 'S18'
WHEN 'S4' THEN 'S4'
ELSE 'UNKNOWN'
END
ORDER BY FAB_PROCESS,FORECAST;

Go to Top of Page
   

- Advertisement -