Problem Query aliased name for calculated field
Hello,
I am hoping that someone else has done this.
I am working on a modification to a ColdFusion site I have inherited and I have to admit that I am more or less a newbie to ColdFusion, although I have worked web applications and Databases for many years.
I am working on a reporting application that output information on requests. The requests can either be completed or delegated. If they are completed the database column comp_time will be populated. If the request is delegated the comp_time column will be null and a column named delegate_date will be populated.
I have come up with the query that will look at both of these fields and and make them into one field. (That part was easy and is highlighted in red)
select sr.request_id,sr.supp_id,sr.entry_date,sr.po_num,(NVL(sr.comp_time, sr.delegate_date)) comp_time,sr.first_article,rd.detail_id,rd.po_line,rd.qty_ready,st.surv_name,rd.qty_expected,rd.qty_accepted,s.supp_name,s.city,sr.delegate_date from source_request sr,request_detail rd,surv_type st,supplier s where 1=1 and rd.surv_type = st.surv_id and sr.request_id = rd.request_id and sr.supp_id = s.supp_id and s.supp_id = 'ZUZ13070' and sr.entry_date >= to_date('10/01/2017', 'MM/DD/YYYY') and sr.entry_date <= to_date('01/31/2018 23:59', 'MM/DD/YYYY HH24:MI') and sr.delegate_date is not null and sr.cancel_date is null
The problem is when I get to the point where I am outputting this to Excel from within the ColdFusion application. The code that does this is:

When I run this code 2 things happen that are not what I am looking for. First the column name is not what the alias should be:

Second I am getting this error when I am processing the results of the query:

Until I added the modified column into the query this worked correctly.
I suspect it is some simple syntax issue but I am not sure how to look for it.
