469,127 Members | 1,289 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,127 developers. It's quick & easy.

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','Fixed',20)
insert into bank values('A1','Deposit',5)
insert into bank values('A1','Fixed',10)
insert into bank values('A2','Fixed',20)
insert into bank values('A2','Deposit',10)

select branch_no,acc_type,SUM(tot_accounts) 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
May 3 '08 #1
2 710
1,134 Expert 1GB
SELECT branch_no,acc_type,SUM(tot_accounts)
FROM bank
GROUP BY branch_no , acc_type
ORDER BY branch_no,acc_type
May 3 '08 #2
Thanks,query Is Solved
May 3 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by unixman | last post: by
6 posts views Thread by Eddie Smit | last post: by
3 posts views Thread by Don Sealer | last post: by
2 posts views Thread by Don Wash | last post: by
3 posts views Thread by John Baker | last post: by
27 posts views Thread by one man army | last post: by
2 posts views Thread by Fendi Baba | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.