tags:

views:

44

answers:

0

Hi, I have problem with inner joining 2 tables.

Table Lookup has only creative name and perf table has the creative name as well as the values to it. i need need to get the values into lookup table (where both the table has common creative name).

Also, creative names have duplicates, so i need to sum them up and get the value. Below is the code what i have used but sum() function seems not to be working as i am seeing the different value when matched against the "perf" table data.

Here is the code i have used

select UCID,/*lookup.[creative name],*/ 
sum(perf.[delivered impressions]) as ttl_del,        
sum(perf.[IMM_SUMMARY])as ttl_WSO,
sum(perf.[clicks]) as ttl_clicks,
sum(perf.[IMM_SUMMARY])/sum(perf.[delivered impressions])*100 as IMM_Score

from ADHOC_NG_UCID_lookup lookup

   INNER JOIN FILTERED_CREATIVE_EXEC_TABLE perf

      ON lookup.[UCID] = perf.[creative name]

where 
perf.[delivered impressions]>0 and perf.[brand] in ('MALIBU') and perf.month in ('APRIL') and perf.[sizes] in('160x600')

group by UCID/*, lookup.[creative name]*/

order by UCID/*, [creative name]*/

Please advice or let me know why the sum() function is not working properly.

Thanks for your support.