Subject | Sub query returns NULL |
---|---|
Author | moegamata |
Post date | 2010-05-17T06:51:24Z |
Hi
I have a problem in that my subquery returns a null value despite the fact that I have it wrapped in a coalesce ... What am I missing?
Many thanx
/M
SELECT
z.salesdate,
sum(w.EXTENDED) SalesTotal,
sum(w.DISCOUNT) Discounts,
(select a.roundloss
FROM round_v a
where a.salesdate = z.salesdate) as RoundLoss,
(select coalesce(a.CreditSales,0)
FROM crdsales_v a
where a.salesdate = z.salesdate) as CreditSales,
..
..
FROM asales z,sales v,salesitems w,salestype x
where z.salesdate between :sdate and :edate
..
..
group by z.salesdate
I have a problem in that my subquery returns a null value despite the fact that I have it wrapped in a coalesce ... What am I missing?
Many thanx
/M
SELECT
z.salesdate,
sum(w.EXTENDED) SalesTotal,
sum(w.DISCOUNT) Discounts,
(select a.roundloss
FROM round_v a
where a.salesdate = z.salesdate) as RoundLoss,
(select coalesce(a.CreditSales,0)
FROM crdsales_v a
where a.salesdate = z.salesdate) as CreditSales,
..
..
FROM asales z,sales v,salesitems w,salestype x
where z.salesdate between :sdate and :edate
..
..
group by z.salesdate