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 2000 Forums
 Transact-SQL (2000)
 Repeated columns

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 displayed
FAIT 10137
FAIT 10213
FAIT 10247
Global Telecom 10138
Global Telecom 10140
Global Telecom 10141
Global Telecom 10222

but I need to display it like this:

FAIT
10137
10213
10247

Global Telecom
10138
10140
10141
10222

Can 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 Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

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.

Go to Top of Page

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 @Sample
SELECT 'FAIT', 10137 UNION ALL
SELECT 'FAIT', 10213 UNION ALL
SELECT 'FAIT', 10247 UNION ALL
SELECT 'Global Telecom', 10138 UNION ALL
SELECT 'Global Telecom', 10140 UNION ALL
SELECT 'Global Telecom', 10141 UNION ALL
SELECT 'Global Telecom', 10222

SELECT COALESCE(Code, GroupName) AS [Output]
FROM (
SELECT GroupName,
Code,
1 AS Header
FROM @Sample

UNION ALL

SELECT DISTINCT GroupName,
NULL,
0
FROM @Sample
) AS d
ORDER BY GroupName,
Header,
Code[/code]


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -