Skip to Content

SQL Query

Hi, please refer to my attachment. Can someone teach me on how to remove those null data? I don't want that null value appear in the row. here is my code :

SELECT T1.[ItemCode], T1.[Dscription] as ItemName, min(case when t6.Code like 'SP OEM%' then t5.Quantity end)as SalesProjectionQty, min(case when t6.Code like 'OEM%' then t5.Quantity end)as ForecastQty, sum(T1.[Quantity]) as TotalQty, sum(T1.[LineTotal]) as LineTotal FROM OINV T0 inner JOIN INV1 T1 ON T0.[DocEntry] = T1.[DocEntry] inner JOIN OCRD T2 ON T0.CardCode = T2.CardCode inner JOIN OCRG T3 ON T2.GroupCode = T3.GroupCode inner JOIN OITM T4 on T4.ItemCode = T1.ItemCode inner join fct1 t5 on t5.ItemCode=t1.ItemCode inner join ofct t6 on t6.AbsID=t5.AbsID WHERE T0.[DocDate] >= '20200701' And T0.[DocDate] <= '20200731' and U_XFSet='N' and month(t5.date)=month(T0.DocDate) and year(t5.date)=year(T0.DocDate) group by T1.[ItemCode], T1.[Dscription] UNION SELECT T1.[ItemCode], T1.[Dscription], min(case when t6.Code like 'SP%' then t5.Quantity end)as SalesProjectionQty, min(case when t6.Code like 'OEM%' then t5.Quantity end)as ForecastQty, sum(T1.[Quantity]/2)*-1 as 'TotalQty', sum(T1.[LineTotal]/2)*-1 as 'LineTotal' FROM ORIN T0 inner JOIN RIN1 T1 ON T0.[DocEntry] = T1.[DocEntry] inner JOIN OCRD T2 ON T0.CardCode = T2.CardCode inner JOIN OCRG T3 ON T2.GroupCode = T3.GroupCode inner JOIN OITM T4 on T4.ItemCode = T1.ItemCode inner join fct1 t5 on t5.ItemCode=t1.ItemCode inner join ofct t6 on t6.AbsID=t5.AbsID WHERE T0.[DocDate] >= '20200701' And T0.[DocDate] <= '20200731' and U_XFSet='N' and month(t5.date)=month(T0.DocDate) and year(t5.date)=year(T0.DocDate) group by T1.[ItemCode], T1.[Dscription]

query.png (52.7 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Aug 04, 2020 at 02:44 AM

    if this was oracle, you can use nvl(min(case when t6.Code like 'SP OEM%' then t5.Quantity end),0)


    if it was other DB platform, you can search the similar function of above.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.