Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select First Record
Message
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Select First Record
Miscellaneous
Thread ID:
00514286
Message ID:
00514286
Views:
39
Dear All:

Suppose we have a table containing data:

TABLE1
code1 code2 year units amount
A C1 2000 1 10 <------ First Record
A C2 2000 2 20
A C3 2000 3 30
A C4 2001 4 40 <------ First Record
A C5 2001 5 50
A C6 2001 6 60
B C1 2000 1 10 <------ First Record
B C2 2000 2 20
B C3 2000 3 30
B C4 2001 4 40 <------ First Record
B C5 2001 5 50
B C6 2001 6 60
C C1 2000 1 10 <------ First Record
C C2 2000 2 20
C C3 2000 3 30
C C4 2001 4 40 <------ First Record
C C5 2001 5 50
C C6 2001 6 60


Is there a way we can create a Select statement whose result must look like this:

Select Result:
code1 code2 year units amount
A C1 2000 1 10
A C4 2001 4 40
B C1 2000 1 10
B C4 2001 4 40
C C1 2000 1 10
C C4 2001 4 40

(Wherein I 'first record' of the select group is selected(as indicated by the Arrows).

2. I had Problems regarding cursors. How can we handle 2 cursors is SQL Procedures.
Next
Reply
Map
View

Click here to load this message in the networking platform