View Single Post
  #5 (permalink)  
Old 02-09-05, 15:10
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 16,084
blindman, your queries are starting to look good

but the join should be outdented

use foo and bar if more than one column is intended (YourColumns alone does not show comma syntax)

and shorter aliases make it easier to read
Code:
select  T.foo, T.bar
from    YourTable as T
  inner join YourTable as Th
        on T.GroupColumns = Th.GroupColumns
        and T.SortColumn <= Th.SortColumn
group by T.foo, T.bar
having count(*) <= n
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote