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
 How to pull lowest two scores
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

craigwg
Posting Yak Master

USA
154 Posts

Posted - 05/24/2010 :  16:44:43  Show Profile  Reply with Quote
I think I have a tough one here. I have written a query that pulls some survey results. The survey has 11 question. My query is working as I intend thus far:



use pdpadmin_dev
select 
	'Center'					= cen.Centername,
	'Subsidiary'				= sub.Subsidiaryname,
	'Manager'					= su.managername, 
	'Supervisor'				= su.supervisorname,
	'Planning and Execution'	= cast(res.skills_planningexecution as float),
	'Time Management'			= cast(res.skills_timemanagement as float),
	'Continuous Improvement'	= cast(res.skills_continuousimprovemen as float),
	'Interpersonal Skills'		= cast(res.skills_interpersonal as float),
	'Communicaiton Skills'		= cast(res.skills_communication as float),
	'Leadership Skills'			= cast(res.skills_leadership as float),
	'Integrity'					= cast(res.culture_integrity as float),
	'Respect'					= cast(res.culture_respect as float),
	'Professionalism'			= cast(res.culture_professionalism as float),
	'Innovation'				= cast(res.culture_innovation as float),
	'Commitment'				= cast(res.culture_commitment as float)
	

from 
	pdpadmin_dev..supervisor su
	INNER JOIN pdp..vw_results_67732 res on su.supervisorid = res.supervisorid and res.questionid=49
	INNER JOIN TPReports..info_center cen on su.center = cen.center
	INNER JOIN TPReports..info_subsidiary sub on cen.subsidiaryid = sub.subsidiaryid
ORDER BY 
	cen.Centername, sub.Subsidiaryname, manager, supervisor


This lists all supervisor answers to the survey and orders them by location, manager, etc. Pretty straight forward.

But, my next task is to return the two lowest scores for each row. Technically I'm after the two categories of the lowest two scores. I'm not sure how to get there though. Can anyone help?

Thanks

Craig Greenwood

zstarsales04
Starting Member

20 Posts

Posted - 05/25/2010 :  02:31:44  Show Profile  Visit zstarsales04's Homepage  Reply with Quote
spam removed
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.33 seconds. Powered By: Snitz Forums 2000