Opening and Closing Value calculate

  • Below is data

    CREATE TABLE #Containerno(CID INT,Contno VARCHAR(50),ConWeight nvarchar(50),Entrydate date ,DelID int)  

    CREATE TABLE #ConIssuance (IID INT,CID INT,QTY INT,IWeight int,Entrydate DATETIME,DelID int)

    INSERT INTO #Containerno VALUES(0,'ABC0000',2000,'2022-01-28',null)
    INSERT INTO #Containerno VALUES(1,'ABC1111',2000,'2022-01-28',null)
    INSERT INTO #Containerno VALUES(2,'ABC1222',1500,'2022-01-30',null)
    INSERT INTO #Containerno VALUES(3,'ABC1333',7800,'2022-02-01',null)
    INSERT INTO #Containerno VALUES(4,'ABC1444',4500,'2022-02-02',null)
    INSERT INTO #Containerno VALUES(5,'ABC1555',4700,'2022-02-15',null)
    INSERT INTO #Containerno VALUES(6,'ABC1666',5000,'2022-02-15',null)
    INSERT INTO #Containerno VALUES(7,'ABC1777',6000,'2022-02-16',null)

    INSERT INTO #ConIssuance VALUES(1001,1,1,1000,'2022-01-29',null)
    INSERT INTO #ConIssuance VALUES(1002,2,1,500,'2022-01-30',null)
    INSERT INTO #ConIssuance VALUES(1003,2,1,500,'2022-02-01',null)
    INSERT INTO #ConIssuance VALUES(1004,3,1,2000,'2022-02-03',null)
    INSERT INTO #ConIssuance VALUES(1005,4,1,1000,'2022-02-03',null)
    INSERT INTO #ConIssuance VALUES(1006,4,1,1000,'2022-02-03',null)
    INSERT INTO #ConIssuance VALUES(1007,3,1,1000,'2022-02-03',null)
    Note: About Columns;
    Contno = Will be retrieve from table #Containerno according to Date between Filter,
    Opening_Weight =What ever closing value before Starting Date Parameter (Opening_Weigt-Isu_Weight)
    Isu_weight = Will be retrieve from table #ConIssuance according to Date Between filter ,
    Closing_Weight = Opening_Weight - Isue_Weight

    I want to pass Date Parameter from 01/02/2022 to 15/02/2022

     

     

    Attachments:
    You must be logged in to view attached files.
  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

  • What queries have you tried out yourself?

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • it is resolved

  • akhterhussain80 wrote:

    it is resolved

    You should post your solution so that we can check it for you... a lot of people make a pretty bad error for things like this.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply