By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,379 Members | 1,380 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,379 IT Pros & Developers. It's quick & easy.

Simple Query

P: 95
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
Share this Question
Share on Google+
2 Replies


Delerna
Expert 100+
P: 1,134
[code]
SELECT branch_no,acc_type,SUM(tot_accounts)
FROM bank
GROUP BY branch_no , acc_type
ORDER BY branch_no,acc_type
[/code
May 3 '08 #2

P: 95
Thanks,query Is Solved
May 3 '08 #3

Post your reply

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