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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How can I rearrange the results of this query?

Author  Topic 

simflex
Constraint Violating Yak Guru

327 Posts

Posted - 2014-03-12 : 21:46:07
Hi,

When I run the following query:



SELECT ElectionName, Position, CandidateName, c.PositionId,CurrentOfficeHolder,AnswerType FROM Candidates c
INNER JOIN Positions p ON c.PositionId = p.PositionId
INNER JOIN Elections e on c.ElectionId = e.ElectionId
WHERE c.ElectionId IN (2,3)
GROUP BY Position, CandidateId, CandidateName,c.PositionId,CurrentOfficeHolder,AnswerType,ElectionName
ORDER BY c.PositionId

I get the following results:

GC Ball Member Jiim Fyre 7 NULL M
GC Ball Member Katty Perry 8 NULL M
CF Ball Member Justine Util 9 NULL M
CF Ball Member Bill Johnson 10 NULL M
CF Ball Member Ann Dawn 11 NULL M


How can I modify the code to show the results in the following format?

GC Ball
Jiim Fyre 7 NULL M
Katty Perry 8 NULL M
CF Ball
Member Justine Util 9 NULL M
Member Bill Johnson 10 NULL M
Member Ann Dawn 11 NULL M


Notice GC and CF are ElectionNames.

We would like to show each ElectionName just one, followed by associated results.

Your help is greatly appreciated

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-03-12 : 23:25:19
This is presentation issue. Do it in your front end application


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -