Posted on 2013-05-13
WHEN coach_drive='C' THEN 'Coach'
WHEN coach_drive='M' THEN 'Mini'
from blood_drives bd,sites s,blood_drives_audit bda
where bd.site_code = s.site_code
and bd.audit_kay = bda.audit_key
and drive_date between '01-may-2013' and '15-may-2013'
and drive_cancelled is null
group by drive_date,drive_id,bd.site_code,site_name,area_rep_no,coach_drive
In the blood_drives_audit I have a field called column_name and the data here is projection. ie column_name = 'projection'
I need a to add this to the query above.
if column_name = 'projection' and the value is not null then take
value from blood_drives_audit table where column_name = projection
else value from blood_drives table
kind of this one
and sum(nvl(bda.column_name,bd.projection)) projection,
Help is appreciated.