Hi there,
I'm trying to use alias column in concate expression but it is not allowing me to use directly,I have tried by using some solutions but ended up with some issues.
Can someone please suggest something on this.Here is my simple query.
- SELECT DISTINCT scm_desc,
- CASE
- WHEN email.subject NOT LIKE '%INC00%' THEN email.create_date
- ELSE NULL
- END AS orgdate,
- CASE
- WHEN tr_status = 'Closed' THEN
- Concat(CONVERT(VARCHAR(5),
- Datediff(s, orgdate,
- tr_modified_on) / 86400)
- , 'D',
- '' + ':'
- +
- CONVERT(VARCHAR(5), Datediff(s,
- orgdate,
- tr_modified_on)%86400/3600), 'H', '' +
- ':'
- +
- CONVERT(VARCHAR(5), Datediff(s, orgdate,
- tr_modified_on)%3600/60), 'M')
- ELSE ''
- END AS overdue
- FROM dbo.ims_transaction
- LEFT JOIN ims_mtr_sub_category
- ON ims_mtr_sub_category.scm_id = ims_transaction.tr_sub_category
- LEFT JOIN dbo.email
- ON email.incident_no = ims_transaction.tr_incident_no
- WHERE tr_status NOT IN( 'stu_CLS' )
-