General information
Forum:
Microsoft SQL Server
Title:
Select First Record
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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only