Skip to Content

Query: Overwrite data in one column with static value

Experts,

I use the Union All function to show Deliveries, Inventory Transfers and Service Call details.

When it shows the Service call details, I need the quantity field to be -1. At this stage, I have it pulling the RemQty as a placeholder.

But when it pulls Deliveries or Inv. Transfers, it needs to pull the REAL quantity.

Here is what I have:

SELECT T0.[DocNum], T0.[ObjType], T0.[CardCode], T0.[CardName], T0.[DocDate], T1.[ItemCode], T1.[Quantity], T1.[WhsCode]

FROM ODLN T0 INNER JOIN DLN1 T1 ON T0.[DocEntry] = T1.[DocEntry]

UNION ALL

SELECT T0.[DocNum], T0.[ObjType], T0.[CardCode], T0.[CardName], T0.[DocDate], T1.[ItemCode], T1.[Quantity], T1.[WhsCode]

FROM OWTR T0 INNER JOIN WTR1 T1 ON T0.[DocEntry] = T1.[DocEntry]

UNION ALL

SELECT T0.[callID], T0.[ObjType], T0.[customer], T0.[custmrName], T0.[createDate], T0.[ItemCode], T0.[RemQty], T0.[customer]

FROM OSCL T0

ORDER BY T0.[CardCode]

Your help would be much appreciated,

Marli

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Aug 16, 2016 at 08:35 AM

    You mean T0.Remqty * -1

    try this

    SELECT T0.[DocNum], T0.[ObjType], T0.[CardCode], T0.[CardName], T0.[DocDate], T1.[ItemCode], T1.[Quantity], T1.[WhsCode]

    FROM ODLN T0 INNER JOIN DLN1 T1 ON T0.[DocEntry] = T1.[DocEntry]

    UNION ALL

    SELECT T0.[DocNum], T0.[ObjType], T0.[CardCode], T0.[CardName], T0.[DocDate], T1.[ItemCode], T1.[Quantity], T1.[WhsCode]

    FROM OWTR T0 INNER JOIN WTR1 T1 ON T0.[DocEntry] = T1.[DocEntry]

    UNION ALL

    SELECT T0.[callID], T0.[ObjType], T0.[customer], T0.[custmrName], T0.[createDate], T0.[ItemCode],T0.[RemQty]*-1 , T0.[customer]

    FROM OSCL T0

    ORDER BY T0.[CardCode]

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 16, 2016 at 01:19 AM

    Just replacing T0.RemQty with -1 should work

    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.