I have the following within a SELECT statement:
...so essentially what I am doing is firstly creating the figure for AnnualRetailPri ce (AnnualRP) using the case statement ("if it is an upgrade campaign and a sale sum the additional premium else take the full price); then adding on any figures for manual sales (sum(annnualrp) from tbl_obmi_manual sales.
To me this seems logical, however, every row has 'null' in the resultant dataset.
I have also tried joining the table on and adding onto the end "+ ManualSales.ann ualRP", but this still returns no records.
Am I unaware of some addition rule here or some other rule?
The query works and gives figures when the addition is taken off, it's just when it's tacked onto the end it gives null values.
Any ideas or pointers please?!
Thanks
J
Code:
: AnnualRP = sum(CASE WHEN Original.CampCode like '%u%' AND(Original.CompletedCode = 24 OR Original.CompletedCode = 25) THEN cast((adprem)*12 as money) WHEN Original.CampCode like '%u%' AND(Original.CompletedCode <> 25 AND Original.CompletedCode <> 24) THEN 0 ELSE cast((Price)*12 as money) END) + (Select cast(sum(annualrp) as money) as annualrp from tbl_obmi_manualsales where date = original.calldate and campcode = original.campcode and democode = original.democode) ....
To me this seems logical, however, every row has 'null' in the resultant dataset.
I have also tried joining the table on and adding onto the end "+ ManualSales.ann ualRP", but this still returns no records.
Am I unaware of some addition rule here or some other rule?
The query works and gives figures when the addition is taken off, it's just when it's tacked onto the end it gives null values.
Any ideas or pointers please?!
Thanks
J
Comment