MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL 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:
  #1  
Old February 25th, 2004, 01:06 AM
iamvijay iamvijay is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 5 iamvijay User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Wanted SlNo for different name.....

I've a query like below (i'm using oracle)

Select Name, Sal From
(Select 'A' Name, 1 Sal From Dual
Union
Select 'A' Name, 2 Sal From Dual
Union
Select 'A' Name, 3 Sal From Dual
Union
Select 'B' Name, 11 Sal From Dual
Union
Select 'C' Name, 111 Sal From Dual
Union
Select 'C' Name, 222 Sal From Dual
Union
Select 'D' Name, 1111 Sal From Dual
Union
Select 'D' Name, 2222 Sal From Dual
Union
Select 'D' Name, 3333 Sal From Dual
Union
Select 'D' Name, 4444 Sal From Dual
Union
Select 'D' Name, 5555 Sal From Dual)

which will return output like

Name SAL
---- ----------
A 1
A 2
A 3
B 11
C 111
C 222
D 1111
D 2222
D 3333
D 4444
D 5555

I want one more column which will display no. for each name like

No Name SAL
-- ---- ----------
1 A 1
1 A 2
1 A 3
2 B 11
3 C 111
3 C 222
4 D 1111
4 D 2222
4 D 3333
4 D 4444
4 D 5555

can anyone help me

thanx in advance

vijay

Reply With Quote
  #2  
Old February 25th, 2004, 01:51 AM
floweringcactus floweringcactus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 floweringcactus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool Re:

Hey,
When u r doing so much creating each column in the dual table n all, why don't u add one more column with the values wanted!!!!

Or u want any other solution..

Reply With Quote
  #3  
Old February 25th, 2004, 05:13 AM
iamvijay iamvijay is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 5 iamvijay User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hi,

that query is just example and just to explain, and i'm not using dual table in actual query, i wanted to generate those nos. dynamically

thx

vijay

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Wanted SlNo for different name.....


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