I would like to split column ‘ASPCT_VLU_NM’ and count of occurrences of the timestamps in a given time frame. For example return the ID which have more than 3 occurrence in between 1537160520286 and 1537190520286.
In the example below those are the timestamps :
Advertisement
Answer
If you are using Teradata 14 or later, then you may take advantage of the STRTOK
function here:
SELECT ID FROM yourTable WHERE CAST(STRTOK(ASPCT_VLU_NM, ',', 4) AS BIGINT) BETWEEN 1537160520286 AND 1537190520286 GROUP BY ID HAVING COUNT(*) > 3;
Note: You may want to give serious consideration to changing your table design, in particular to not storing CSV data in the ASPCT_VLU_NM
column. Instead, get each CSV value into a separate row/column.