Row count question

  •  

    Folks,

    I'm looking to modify the SQL below to develop a temp table with a row count. At the moment it assigned a counter for every record in the 'sales' table regardless of any filter in the where clause. Can anyone help me get the counter to only include those records as specified by the where clause. You see the row counter starts at 4 because there are 3 records where order <'6871'

    I have used the 'pubs' database from SQL server

    use pubs

    select a1.ord_num,count(a2.ord_num)as counter

    from(select sales.ord_num,count(sales.ord_num)as jcount from sales group by sales.ord_num)a1,

    (select sales.ord_num,count(sales.ord_num)as jcount from sales group by sales.ord_num)a2

    where a1.ord_num>=a2.ord_num and a1.ord_num >'6871'

    group by a1.ord_num, a1.jcount

    this would really dig me out of a hole, so thanks in advance

    regards

    James

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply