DB2 Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDB2 Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old March 27th, 2008, 05:38 AM
vishal0soni vishal0soni is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 1 vishal0soni User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 45 sec
Reputation Power: 0
Post Need Query for Connected numbers

I have a simple scenario.
there is a chain of numbers connected together,
say 1-2-3-4-5.
This chain is present in a table(number,grp), which represent each connection between two numbers as two different records, having same grp id.
for connection 1-2, we have two records, both having same grp id.
In my table, the chain is represented as following
---------------
number grp
---------------
1 1
2 1
2 2
3 2
3 3
4 3
4 4
5 4

But assignemt of grp ids is occuring randomly.
i.e., we might have the same chain as
---------------
number grp
---------------
1 2
2 2
2 1
3 1
3 4
4 4
4 5
5 5

Now how can i derive my original chain (in same order 1-2-3-4-5) using any SQL statement.

Reply With Quote
  #2  
Old March 27th, 2008, 05:56 AM
Annie79's Avatar
Annie79 Annie79 is offline
Meow Black Belt
Click here for more information
 
Join Date: Oct 2005
Location: Beaverton OR
Posts: 913 Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Annie79 User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)  Folding Points: 47372 Folding Title: Beginner FolderFolding Points: 47372 Folding Title: Beginner FolderFolding Points: 47372 Folding Title: Beginner Folder
Time spent in forums: 4 Weeks 7 h 50 m 59 sec
Reputation Power: 433
sql Code:
Original - sql Code
  1. SELECT number, grp FROM mytable ORDER BY number, grp 
__________________

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDB2 Development > Need Query for Connected numbers


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway