Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 17th, 2005, 04:57 AM
Registered User
 
Join Date: Jun 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem-Specific SQL Query

Hello Everyone,

Please get me the solution for the problem specified below:

Consider a table >

Column Name A B

              23 g
              26 m
              23 h
              55 a
              26 k
              23 s

I have to come up with a SQL query which can provide me with the output >

              23 g, h, s
              26 m, k
              55 a

Regards,
Rahul

 
Old June 17th, 2005, 09:43 AM
Registered User
 
Join Date: Jun 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

select * from test order by no1,no2

Amit
 
Old June 17th, 2005, 10:18 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:
 select * from test order by no1,no2
No, that's not what the OP asked for.

Actually, the only way to do this in a supported and well defined way is to use a cursor (ugh). The operation is called "string aggregation" and there are ways to accomplish this, it's just that most of them cannot guarantee that the aggregation will always result in the same output, or rather, the same same order of the output (sub)strings.

Refer to this topic:
http://p2p.wrox.com/topic.asp?TOPIC_ID=6611

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Query problem skarthikk SQL Server 2000 1 August 7th, 2006 02:20 AM
SQL Query problem caterpillar SQL Server 2000 2 August 2nd, 2006 07:59 PM
Problem with inserting specific chars in query Paula222 ADO.NET 2 July 16th, 2006 01:52 AM
SQL query problem - Need Help Settt Biztalk 0 September 12th, 2005 09:32 AM
Sql Query Problem mateenmohd SQL Language 0 January 13th, 2004 05:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.