Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
newtosql
Starting Member
4 Posts |
Posted - 2004-09-03 : 09:28:07
|
| I have a Table called Accountit has three field 1.Account_no2.Customer_id3.balanceAccount_No is Unique.Customer_Id field has multiple records for same customer_id.balance has different values.I want a single query that gives you a small report of the customer_id and how many account it has.this is the sample scenario of tableaccount_No==== Customer_id====balance=======================================123===1===100234===1===300345===2===8000456===2===900768===2===1000999===2===10000888===3===500987===4===600789===4===900765===4===1001555===5===2000666===1===100444===3===500222===3===400I want a single query that gives you a small report of the customer_id and how many accounts it has.Please Help me. |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2004-09-03 : 09:36:21
|
| Select customer_Id, NumOfAccounts = count(*) From Account Group By customer_IdCorey |
 |
|
|
newtosql
Starting Member
4 Posts |
Posted - 2004-09-03 : 09:41:39
|
| Thank you Corey. I appreciate help. |
 |
|
|
newtosql
Starting Member
4 Posts |
Posted - 2004-09-03 : 11:08:25
|
| How to display the customer having more than two account |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-09-03 : 11:12:57
|
| Select customer_Id, NumOfAccounts = count(*) From Account Group By customer_Idhaving count(*) > 2Go with the flow & have fun! Else fight the flow :) |
 |
|
|
newtosql
Starting Member
4 Posts |
Posted - 2004-09-03 : 11:16:26
|
| Thanx again. |
 |
|
|
|
|
|