Hello All,
I am new to SQL. I am getting error. Please, help me
With status as(
Select
lemnum,
count(
case when status = 'COMP' then linenum end
) as COMP_line,
count(
case when status = 'POSTED' then linenum end
) as POSTED_line,
count(
case when status = 'SUBMIT' then linenum end
) as SUBMIT_line,
count(
case when status = 'WAPPR' then linenum end
) as WAPPR_line
FROM
BI_HZ_ETL.LEM_FACTS
Group by
lemnum
)
SELECT
status.*,
v.vendor_name,
lf.LINENUM,
lf.LEMNUM,
lf.VENDOR,
lf.WORKDATE,
lf.SITEID,
lf.laborhrs,
lf.equiphrs
FROM
BI_HZ_ETL.LEM_FACTS lf
join status on (LEMNum = lf.LEMNUM)
Left JOIN bi_hz_etl.LEM_vendor v ON (lf.vendor = v.vendor_id)
where
lf.siteid in('HORIZON', 'ALBIAN') and STATUS not in('DELETED', 'NEW', 'REJECT')
Thanks