SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Error
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

joefor
Starting Member

2 Posts

Posted - 06/24/2013 :  13:35:27  Show Profile  Reply with Quote
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

India
52309 Posts

Posted - 06/24/2013 :  13:37:23  Show Profile  Reply with Quote

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

Edited by - visakh16 on 06/24/2013 13:37:55
Go to Top of Page

joefor
Starting Member

2 Posts

Posted - 06/24/2013 :  13:47:56  Show Profile  Reply with Quote
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

547 Posts

Posted - 06/24/2013 :  14:02:11  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000