I am looking to concatenate 2 columns in my sql code. I want 'Name' + 'Margin_Account' to show as 1 with a fullstop in the middle. An example: Name = XYZ, Margin_Account = A. I want a new column called 'Member_Account' to look as "XYZ.A". How can I do this? I am unsure on how to do this given I would require a fullstop in the middle of the Name + Margin_Account to make the new column. This my code:
SELECT to_char(intraday_run_time, 'HH24:Mi') as runtime,
to_char(intraday_run_time, 'dd-mon-yyyy') as business_date,
REPORT_AMOUNT,
DESCRIPTION,
MARGIN_ACCOUNT,
NAME,
LEGAL_NAME,
case
when to_char(intraday_run_time, 'HH24') < 9 then 'EARLY'
when to_char(intraday_run_time, 'HH24') < 18 then 'MIDDLE'
when to_char(intraday_run_time, 'HH24') >= 18 then 'LATE'
else 'ERROR'
end as time_of_day,
case
when to_char(intraday_run_time, 'dd-mon-yyy') > add_months(sysdate,-3) then '3month'
else 'ERROR'
end as lookback3,
case when to_char(intraday_run_time, 'dd-mon-yyy') > add_months(sysdate,-6)
then '6month'
else 'ERROR'
end as lookback6,
case
when to_char(intraday_run_time, 'dd-mon-yyy') > add_months(sysdate,-12)
then '12month'
else 'ERROR' end as lookback12
FROM MEMBER_MANAGER.itd_margin_call_run_log_detail itd
JOIN (
SELECT DISTINCT
MARGIN_CALL_RUN_DETAIL_ID,
DESCRIPTION,
margin_account,
name,
legal_name
FROM member_manager.margin_call_run_log_detail a
inner join member_manager.organization b
on a.organization_ID=b.id
) des
ON des.MARGIN_CALL_RUN_DETAIL_ID = itd.MARGIN_CALL_RUN_DETAIL_ID
WHERE REPORT_AMOUNT IS NOT NULL
AND DESCRIPTION in( 'Intraday Margin Call from ECS Call Amount Combined', 'Manually Added' )
AND TRUNC(intraday_run_time) between add_months(sysdate,-12) and sysdate
order by 1 desc