Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A GROUPing question

Status
Not open for further replies.

VickyC

Technical User
Sep 25, 2010
206
CA
hi to all

Consider a table like this...
Code:
 [bold]

Term    Rank     K   [/bold]
 1       1       1
 1       2       1
 1       3       0
 1       4       0
 1       5       1
 1       6       0
 1       7       0
 1       8       0
 1       9       1
 1      10       0

 2       1       0
 2       2       0
 2       3       0
 2       4       1
 2       5       0
 2       6       0
 2       7       1
 2       8       0
 2       9       1
 2      10       0

 3   etc...


Term runs from 1 to 1024, consecutively, with each value of Term having Rank values from 1 to 10. K is 1 or 0.

I want to GROUP BY Term and K, but... I need to show the COUNT of each local grouping of 0 and 1.


The output would look like this, ORDERed BY TERM, FirstOfRank...

Code:
 [bold] [u]

Term    FirstOfRank      K     LocalGroupCount   [/bold]
 1           1           1             2
 1           3           0             2
 1           5           1             1      
 1           6           0             3
 1           9           1             1
 1          10           0             1

 2           1           0             3
 2           4           1             1
 2           5           0             2
 2           7           1             1
 2           8           0             1
 2           9           1             1
 2          10           0             1

 3 etc...

Thanks in anvance for any help
Vicky C


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top