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
 How to pull lowest two scores

Author  Topic 

craigwg
Posting Yak Master

154 Posts

Posted - 2010-05-24 : 16:44:43
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 - 2010-05-25 : 02:31:44
spam removed
Go to Top of Page
   

- Advertisement -