I'm pretty new at sql, and hoping that someone can help me out. What I'm hoping for is some advice on how to get locations that have not received, or purchased an item for there collection. In addition to the ones that have. I would like to put a general number or null into the value field.
select
location, count(*) as [value]
from
item
where
creation_date >= datediff (dd, '1 Jan 1970', '1 January 2017')
and creation_date <= datediff (dd, '1 Jan 1970', '31 December 2017')
and collection in ('ab', 'blu', 'cd', 'dvd', 'eab', 'ecd', 'edvd', 'frdvd', 'jab', 'jcd', 'jdvd', 'mus', 'vg', 'yaab', 'yacd', 'yadvd')
and location in ('aal', 'aali', 'aami')
and item# not in (select item# from po_line_item where item# is not null)
---insert horrible stuff here to get total counts by location
or (item# in (select item#
from po_line_item
where receive_date >= datediff (dd, '1 Jan 1970', '1 January 2017')
and receive_date <= datediff (dd, '1 Jan 1970', '31 December 2017')
)
and collection in ('ab','blu','cd','dvd','eab','ecd','edvd','frdvd','jab','jcd','jdvd','mus','vg','yaab','yacd','yadvd')
and location IN ('aal', 'aali', 'aami')
)
group by
location
order by
location