Archives of the TeradataForum
Message Posted: Wed, 20 Jan 2010 @ 14:54:00 GMT
Subj: | | Re: Workaround to avoid product join |
|
From: | | Victor Sokovin |
> 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 Table A A ,
> Ref_table R
> WHERE R.ID_MINUTE between A.MINUTE_STARTING and A.MINUTE_ENDING
> GROUP BY A.ID_PROD ,
> R.ID_MINUTE
Sorry, forget to ask whether
case when R.ID_MINUTE = A.MINUTE_STARTING
THEN A.SEC_FIRST_MIN
should be
case when R.ID_MINUTE = A.MINUTE_STARTING
THEN 60 - A.SEC_FIRST_MIN ?
Does not matter for the question but it would improve the understanding of what is going on in the query.
Victor
|