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 |
|
getur.srikanth@gmail.com
Yak Posting Veteran
77 Posts |
Posted - 2008-03-03 : 16:40:48
|
| Hi,I have two tables customers and orders. customerID is the foreign key for order table. If I pass customername I need to get information about each customer how many orders holding? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-03-03 : 16:45:32
|
But if you pass a customername, you will get orders for that customer only. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-03-03 : 16:46:27
|
SELECT c.CustomerName, COUNT(o.CustomerID)FROM Customers AS cLEFT JOIN Orders AS o ON o.CustomerID = c.IDGROUP BY c.CustomerNameORDER BY c.CustomerName E 12°55'05.25"N 56°04'39.16" |
 |
|
|
getur.srikanth@gmail.com
Yak Posting Veteran
77 Posts |
Posted - 2008-03-03 : 17:15:42
|
Thanks, I got itquote: Originally posted by Peso SELECT c.CustomerName, COUNT(o.CustomerID)FROM Customers AS cLEFT JOIN Orders AS o ON o.CustomerID = c.IDGROUP BY c.CustomerNameORDER BY c.CustomerName E 12°55'05.25"N 56°04'39.16"
|
 |
|
|
|
|
|