There is a table SC_SHIPPED_UNBILLED.It has columns as below in the query.
There are cases where a PRODUCT_SKU in the table has all the info populated except null for vendorpo,extd_cost,VENDOR_CODE due to some application error.
Iam trying to display data in a report, so that when I come across null value for
for the above 4 columns for a PRODUCT_SKU,I have to display the last VENDOR_PO_NUM as a text "LAST PO DATA",the others with the latest column data for that product_sku .
Any idea on how this can be achieved at the query level itself.Iam trying to get the latest row to be shown on the report.
Basically the query used is:
select PROGRAM_CODE, CUSTOMER_CODE as CUSTOMER_NO, CONTROL_NO, SALES_ITEM_NO, SHIPMENT_NO, DATESHIPPED, VENDOR_CODE, VENDOR_PO_NUM, GOODS_RECEIPT_NO, PRODUCT_SKU, NATIONAL_STOCK_NUMBER, QTYSHIPPED, QTYINVOICED, EXT_UNIT_COST as EXTD_COST, EXT_SELLING_PRICE as EXTD_SP, (EXT_SELLING_PRICE-EXT_UNIT_COST) AS GM_DOLLAR_AMT, CASE WHEN EXT_SELLING_PRICE = 0 THEN 0 ELSE ((EXT_SELLING_PRICE-EXT_UNIT_COST)/EXT_SELLING_PRICE) END AS GM_PERCENTfrom SC_SHIPPED_UNBILLED
Instead of trying to explain it, can you post some sample data and expected results?