1369 0
SUM and JOIN 2 columns with different tables but do not SUM Qty

Good day!

Need help to SUM and JOIN 2 columns with different tables but do no want to SUM qty and duplicates row result

here's the sample data tables;

 

Transfer Shipment table;

TransTO - TransFROM -  ItemNo   -   Desc   -   Desc2   -   VariantCode   -   Qty

Location1      HO                Item01         Active      Black         Variant01             5           <------ Delivery

Location1      HO                 Item01         Active      Black        Variant01             5           <------ Delivery

HO                Location1       Item01         Active     Black        Variant01             2          <------ Pull-out

HO                Location1       Item01         Active      Black       Variant01             1            <------ Pull-out

 

Sales Entry table;

Loc Code   -   Item No   -   Variant Code   -   Qty

Location1       Item01          Variant01            -1       <------ PSales

Location1       Item01          Variant01            -1       <------ PSales

 

Item Entry table;

Loc Code   -   Item No   -   Desc   -   Desc2- VariantCode-   Qty - EntryType  - DocNo

Location1       Item01         Active     Black         Variant01      4         2           ItemAdj0001   <------ PAdj

Location1       Item01         Active     Black         Variant01      1          2           StrAdj0001       <------ PAdj

Location1       Item01         Active     Black         Variant01     -1          1           MSales0001     <------ MSales

Location1       Item01         Active     Black         Variant01     -1           1           MSales0002     <------ MSales

Location1       Item01         Active     Black         Variant01     -1          3           LocAdj0005      <------ NAdj

Location1       Item01         Active     Black         Variant01     -1          3           BtqAdj0008      <------ NAdj

 

SUM and JOIN (the sql query result should be like this)

Loc Code  - Item No - Desc  - Desc2 -VarCode- Delivery -PAdj- Pull-out - PSales - MSales - NAdj  -  Total

Location1    Item01   Active    Black   Variant01     10            5           3             -2             -2         -2            6

 

here's my sql query code;

...
Type
Question
1325 0
How to update table variable in stored procedure from another user defined function in sql?

Scenario : User defined function return one table. If that table contains at least one row,one column in the table variable from another sp should get updated.

Should I use cross join on UDF to update table variable?

sql

...
Type
Question
1316 0
Difference between SQL and NoSQL (SQL vs NoSQL)
In this article, I have provided details of what is difference between SQL and NoSQL or you can say providing details of SQL vs NoSQL.
Type
Article
1271 0
Best Open Source Database Software (DBMS)
In this article, I have mentioned Best free and Open Source Database Software (DBMS), which you can use.
Type
Article
1233 1
There is error while executing stored procedure

Getting error in SQL server stored procedure when executing it:

...
Type
Question

1166 0
If-Else in SQL Server with Example
In this article, I have mentioned how we can include if-else in SQL Server Query with an example
Type
Article
1155 0
Find nth highest salary in SQL Server
In this article, I have mentioned few possible query to get Nth highest salary or 3rd highest salary in SQL Server.
Type
Article
1129 0
Union vs Union All in sql server
In this article, I have mentioned what is difference between Union and Union All in SQL Server with example.
Type
Article
927 0
Window functions in sql server
In this article, I have mentioned what is window function in sql server and how to use window function in sql server with example
Type
Article
915 0
Find Duplicate Rows in SQL Server
In this article, I have mentioned how we can find duplicate rows of a table using SQL Server Query with an example.
Type
Article

Page 10 of 11