Simple Query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sonia.sardana
    New Member
    • Jul 2006
    • 95

    #1

    Simple Query

    Find Out the total no of Accounts segregated on the basis of account type person.

    create table bank(branch_no varchar(95),acc _type varchar(20),
    tot_accounts int)

    insert into bank values('A1','Fi xed',20)
    insert into bank values('A1','De posit',5)
    insert into bank values('A1','Fi xed',10)
    insert into bank values('A2','Fi xed',20)
    insert into bank values('A2','De posit',10)

    select branch_no,acc_t ype,SUM(tot_acc ounts) from bank GROUP BY branch_no , acc_type

    Result is coming out to be-
    A1 Deposit 5
    A2 Deposit 10
    A1 Fixed 30
    A2 Fixed 20

    I want first all the accounts of branch A1 are shown then Branch A2.
    I want as follows-
    A1 Deposit 5
    A1 Fixed 30
    A2 Deposit 10
    A2 Fixed 20
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    [code]
    SELECT branch_no,acc_t ype,SUM(tot_acc ounts)
    FROM bank
    GROUP BY branch_no , acc_type
    ORDER BY branch_no,acc_t ype
    [/code

    Comment

    • sonia.sardana
      New Member
      • Jul 2006
      • 95

      #3
      Thanks,query Is Solved

      Comment

      Working...