Skip to content

Instantly share code, notes, and snippets.

@BhargaviTelpunuri
Last active June 9, 2017 04:22
Show Gist options
  • Save BhargaviTelpunuri/9efd8124337fd141fb415eca3fc5f00a to your computer and use it in GitHub Desktop.
Save BhargaviTelpunuri/9efd8124337fd141fb415eca3fc5f00a to your computer and use it in GitHub Desktop.
p
select * from (SELECT 'FPS' Level ,sh.SHOP_NO Geography
,CASE
WHEN st.PRODUCT_ID = 1
THEN sum(qty)
ELSE 0
END Rice_PH
,CASE
WHEN st.PRODUCT_ID = 2
THEN sum(qty)
ELSE 0
END Wheat
,CASE
WHEN st.PRODUCT_ID = 4
THEN sum(qty)
ELSE 0
END Rice_A
FROM STOCK_HEADER_P sh
,STOCK_TRAILER_P st
WHERE sh.DN_SEQ_NO = st.DN_SEQ_NO group by sh.shop_no,st.PRODUCT_ID ) a,STOCK_INVENTORY_P si where a.Geography=si.SHOP_NO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment