How do I fill in the values of a query column with computation? RRS feed

  • Question

  • Hello;

    I've written a query that executes correctly and extracts the information from the tables.

    Suppose this is a query and the table below is its output، and suppose the number of output rows is too large.

    I've considered a col4 column whose value is derived from computing the values in a number of tables.

    In fact, I need to add the loop to the end of the query to execute the loop immediately after the select executes and fill in col4 values.

    But I don't know how to write a loop، And I don't know if anything like this is possible?!

    Note that TbOutput is not a table, but the output of SELECT .... From .... Where ....


    Select ...... From .... Where ....
    For i=0 to TbOutput.rows.count-1
    If ( already calculated, take the value from col4, Read previously calculated and save the current row for col4)
    select c1 from tb1 where colX= TbOutput.rows(i)(col1)
    Dim x = f(c1)
    Comment f(c1):   There is an example computational function that finds and calculates values from different tables
    TbOutput.rows(i)(col4) = x
    End if


    Col1       Col2           Col3           Col4


    a             20             2018              ?

    b             45             2017.             ?

    a             30             2018.             ?

    c             .                .                      ?

    d.            .                .

    c              .                .

    • Edited by Ashkan209 Sunday, November 10, 2019 8:25 PM
    Sunday, November 10, 2019 8:22 PM

All replies

  • Hi Ashkan209,


    Your description is a bit difficult to understand, Would you please provide us some sample data and expected results


    Best regards,

    Dedmon Dai

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Monday, November 11, 2019 8:54 AM