Displaying rows in SQL Server where COUNT = 0 -



Displaying rows in SQL Server where COUNT = 0 -

the next query returns part names regions there have been orders.

select r.regionname, count (distinct o.uid) orders o left bring together customers c on o.customerid = c.uid left bring together regions r on c.region = r.uid (r.regionname not 'null') , (r.regionname <> '') , (r.regionname not 'region 1') , (o.dateordered '7%2011%') grouping r.regionname order r.regionname

how can modify part names show when "count" "0"?

you need either alter join regions right join or create regions from table , join other tables there.

i prefer sec method, since seems more intuitive me. care regions here , you're trying info regions, should in from (imo):

select r.regionname, count(o.uid) regions r left outer bring together customers c on c.region = r.uid -- don't naming convention left outer bring together orders o on o.customerid = c.uid , o.dateordered '7%2011%' -- date stored string? ugh! r.regionname <> 'null' , -- bad... r.regionname <> '' , r.regionname <> 'region 1' grouping r.regionname order r.regionname

sql sql-server tsql

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -