Home > Archive > MS SQL Server > March 2006 > How to add the lost keys









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to add the lost keys
ad

2006-03-08, 8:23 pm

There are four areas in my compay: E, W, S, N.
When I use aggregate function to count to order number of each area, there
maybe some area disappear
in the result, like

select Area, Count(*) from orders

Area OrderCount
----------------------
E 12
W 15
N 14

But I want to result to

Area OrderCount
----------------------
E 12
W 15
S (null or 0)
N 14

How can I do?




Jens

2006-03-08, 8:23 pm

select A.Area, Count(*)
from orders O
LEFT JOIN Areas A
ON A.Area = O.Area

That should help.

Jens Suessmeyer.

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com