Discussion:
[firebird-support] JOIN ON SELECT PROCEDURE
hugo.larson@yahoo.com [firebird-support]
2016-12-06 07:18:55 UTC
Permalink
Hello,

I wonder if I could get help on the following issue.

I have a PROCEDURE GETDATES which returns all the dates of a month.
2016-12-01
2016-12-02
....

And this table

TABLE DEBIT
ID (INT)
DEBITTIME (TIMESTAMP)
TOTALSALE (BIGDECIMAL)

Every day has multiple row of table DEBIT

The request is a report with row of all days of the months (one per day) fetched from the procedure aggregated on each day
If no sale occurred still that date from the procedure should be returned from the query with null aggregated
TOTALSALE.

Example:
2016-12-01 null
2016-12-02 2254,54
2016-12-03 125,25
2016-12-04 null

I tried the following but it does not work.

select gd.DAYS, sum(DEBIT.TOTALSALE )
from DEBIT
left join GETDATES('2016-12-01') gd on gd.DAYS = cast(debit.timedebit as date)
and debit.TIMEDEBIT between '2016-12-01' and '2016-12-31'
group by 1

Any help is very appreciated.

Hugo Larson
Dimitry Sibiryakov sd@ibphoenix.com [firebird-support]
2016-12-06 10:02:41 UTC
Permalink
*I tried the following but it does not work. *
Your join must be right, not left in this case.
--
WBR, SD.


------------------------------------

------------------------------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu. Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------

Yahoo Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-***@yahoogroups.com
firebird-support-***@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-***@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/
hugo.larson@yahoo.com [firebird-support]
2016-12-06 12:18:03 UTC
Permalink
Thanks Dimitry.

BR,
Hugo
hugo.larson@yahoo.com [firebird-support]
2016-12-06 12:22:03 UTC
Permalink
Thanks.

Loading...