I tried to separate two columns from the joined tables, but the result (column relative_duration value) is always 0. The query is as follows:
SELECT t1.[user_1] ,t1.[user_2] ,t1.[total_duration] ,(t1.total_duration/t2.[total_events_duration]) AS relative_duration FROM [CDRs].[dbo].[aggregate_monthly_events] AS t1 INNER JOIN [CDRs].[dbo].[user_events_monthly_stats] AS t2 ON t1.[user_1] = t2.[user_1]
Does anyone know what might be wrong in the above query and how to fix it to split the total_duration column from table t1 into the total_events_duration column from table t2?
BTW I tried to replace the division by subtraction ("/" by "-"), in which case the relative length of the column is not 0.
source share