SQL Server Performance

query SQL 2000

Discussion in 'Getting Started' started by sonalshastry, Dec 2, 2009.

  1. sonalshastry New Member

    I have a bill table with following detailClient, bill_date,bill_amount, branch ...I need to fetch data for top 5 client from every branch below query gives me the data across for A branch
    Code:
    SELECT TOP 5 * FROM (Select Client_id, branch , sum(bill_amount)amountfrom dbo.billtablewhere trade_date >= '01 oct 2009' and trade_date CODE]for all the branches i dont want to hard code the branch value as there are around 900 branchesthere is one more table which contain branch names, for do while loop to take branch name as a variable for extraction , I need to write a function can someone please suggest how to write function in SQL 2000please help 
  2. FrankKalis Moderator

  3. Madhivanan Moderator

Share This Page