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.
Author |
Topic |
liz_50979
Starting Member
2 Posts |
Posted - 2008-05-28 : 13:52:39
|
Hi!!I need to create a query that will only show once the group name but that displays the different codes assigned to that group.The trouble is that there are differente group names but each have many codes assigned to them.This is how my info is displayedFAIT 10137FAIT 10213FAIT 10247Global Telecom 10138Global Telecom 10140Global Telecom 10141Global Telecom 10222but I need to display it like this:FAIT 101371021310247Global Telecom 10138101401014110222Can anyone help me?Thanks a lot |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-05-28 : 13:54:19
|
This is a presentation issue. Display your data how you want it via your application code and not in SQL Server.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
|
|
liz_50979
Starting Member
2 Posts |
Posted - 2008-05-28 : 18:18:50
|
Do you have an example of a similar code, the thing is that this information has to be contained on a stored procedure that has to send an email.Thanks a lot for your help.Regards. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-29 : 02:47:19
|
[code]DECLARE @Sample TABLE (GroupName VARCHAR(20), Code VARCHAR(7))INSERT @SampleSELECT 'FAIT', 10137 UNION ALLSELECT 'FAIT', 10213 UNION ALLSELECT 'FAIT', 10247 UNION ALLSELECT 'Global Telecom', 10138 UNION ALLSELECT 'Global Telecom', 10140 UNION ALLSELECT 'Global Telecom', 10141 UNION ALLSELECT 'Global Telecom', 10222SELECT COALESCE(Code, GroupName) AS [Output]FROM ( SELECT GroupName, Code, 1 AS Header FROM @Sample UNION ALL SELECT DISTINCT GroupName, NULL, 0 FROM @Sample ) AS dORDER BY GroupName, Header, Code[/code] E 12°55'05.25"N 56°04'39.16" |
|
|
|
|
|
|
|