SV: [firebird-support] How do you 0/null results to a GROUP BY query

2012-10-29 Thread Svein Erling Tysvær
>Thanks! I will most likely go with the reference table(s) option, but I >will test both. One alternative that I don't think have been mentioned, Cornie, is EXECUTE BLOCK, which is simpler than a recursive CTE without requiring any extra table: execute block returns (yearno integer, dayno integ

Re: [firebird-support] How do you 0/null results to a GROUP BY query

2012-10-24 Thread Cornie van Schoor
>>> I have query which extract the sales per day from a table > > >>> > >>> Select EXTRACT(YEAR from DT) as YEARNO, EXTRACT(YEARDAY from DT) > AS DAYNO, SUM(DUE) from CLIENT_INVOICES group by YEARNO, WEEKNO. > >>> > >>> It works 100%, but only returns the dates with sales, I need it to > also in

Re: [firebird-support] How do you 0/null results to a GROUP BY query

2012-10-24 Thread Alexandre Benson Smith
Em 24/10/2012 20:37, Doug Chamberlin escreveu: > On 10/24/12 6:25 PM, Alexandre Benson Smith wrote: >> Em 24/10/2012 20:21, Doug Chamberlin escreveu: >>> On 10/24/12 5:54 PM, cornievs wrote: I have query which extract the sales per day from a table Select EXTRACT(YEAR from DT) as YEA

Re: [firebird-support] How do you 0/null results to a GROUP BY query

2012-10-24 Thread Doug Chamberlin
On 10/24/12 6:25 PM, Alexandre Benson Smith wrote: > Em 24/10/2012 20:21, Doug Chamberlin escreveu: >> On 10/24/12 5:54 PM, cornievs wrote: >>> I have query which extract the sales per day from a table >>> >>> Select EXTRACT(YEAR from DT) as YEARNO, EXTRACT(YEARDAY from DT) AS DAYNO, >>> SUM(DUE)

Re: [firebird-support] How do you 0/null results to a GROUP BY query

2012-10-24 Thread Alexandre Benson Smith
Em 24/10/2012 20:21, Doug Chamberlin escreveu: > On 10/24/12 5:54 PM, cornievs wrote: >> I have query which extract the sales per day from a table >> >> Select EXTRACT(YEAR from DT) as YEARNO, EXTRACT(YEARDAY from DT) AS DAYNO, >> SUM(DUE) from CLIENT_INVOICES group by YEARNO, WEEKNO. >> >> It wor

Re: [firebird-support] How do you 0/null results to a GROUP BY query

2012-10-24 Thread Doug Chamberlin
On 10/24/12 5:54 PM, cornievs wrote: > I have query which extract the sales per day from a table > > Select EXTRACT(YEAR from DT) as YEARNO, EXTRACT(YEARDAY from DT) AS DAYNO, > SUM(DUE) from CLIENT_INVOICES group by YEARNO, WEEKNO. > > It works 100%, but only returns the dates with sales, I need

Re: [firebird-support] How do you 0/null results to a GROUP BY query

2012-10-24 Thread Louis Kleiman (SSTMS, Inc.)
But this won't return rows for dates where there is no record in the source table. On Wed, Oct 24, 2012 at 6:02 PM, Leyne, Sean wrote: > ** > > > > > I have query which extract the sales per day from a table > > > > Select EXTRACT(YEAR from DT) as YEARNO, EXTRACT(YEARDAY from DT) AS > > DAYNO, SU

Re: [firebird-support] How do you 0/null results to a GROUP BY query

2012-10-24 Thread Alexandre Benson Smith
try something like this: with recursive Datas (Data) as (select Cast('2009-01-01' as Date) From rdb$database union all Select Data + 1 From Datas Where Data + 1 <= Cast('2009-01-31' as Date)) select

RE: [firebird-support] How do you 0/null results to a GROUP BY query

2012-10-24 Thread Leyne, Sean
> I have query which extract the sales per day from a table > > Select EXTRACT(YEAR from DT) as YEARNO, EXTRACT(YEARDAY from DT) AS > DAYNO, SUM(DUE) from CLIENT_INVOICES group by YEARNO, WEEKNO. > > It works 100%, but only returns the dates with sales, I need it to also > include > the dates w

[firebird-support] How do you 0/null results to a GROUP BY query

2012-10-24 Thread cornievs
Hi All I have query which extract the sales per day from a table Select EXTRACT(YEAR from DT) as YEARNO, EXTRACT(YEARDAY from DT) AS DAYNO, SUM(DUE) from CLIENT_INVOICES group by YEARNO, WEEKNO. It works 100%, but only returns the dates with sales, I need it to also include the dates with zero