|
|
Archives of the TeradataForum
Message Posted: Wed, 20 Jan 2010 @ 10:43:50 GMT
Subj: | | Re: Workaround to avoid product join |
|
From: | | Dmitriy.Boyko |
Hi!
Try this:
SELECT
A.ID_PROD,
R.ID_MINUTE,
SUM(CASE WHEN R.ID_MINUTE = A.MINUTE_STARTING THEN A.SEC_FIRST_MIN WHEN R.ID_MINUTE =
A.MINUTE_ENDING THEN A.SEC_LAST_MIN ELSE 60 END) NB_SECONDS_SLICE FROM A A, Ref_table R
WHERE R.ID_MINUTE BETWEEN A.MINUTE_STARTING AND A.MINUTE_ENDING
AND r.id_minute * 0 = a.minute_starting * 0 -- Added by me GROUP BY A.ID_PROD, R.ID_MINUTE
There is merge join, but I don't know whether performance is good. Please, try it and report the result.
Best regards,
Dmitriy Boyko
| |