Skip to Content
0
Former Member
Jun 08, 2020 at 10:44 PM

How to write a SELECT statement based on the year and period of Parameters

795 Views

Nice to meet you, experts

What kind of logic should be used when the program uses the fiscal year and fiscal period of PARAMETERS and narrows down the data to be acquired by the SELECT statement?

(I want to obtain only the latest data for the year and period entered in PARAMETERS.)

For example, the following values exist in the table.

No. LFGJA LFMON DMBTR

1 2019 2 1000

2 2018 12 500

3 2018 10 300

At PARAMETERS

Year: 2019

Period: 1

If entered, No.2 (2018 12 500)

Only get and

Year: 2019

Period: 3

If entered, No.1 (2019 1 1000)

I want to write logic such as getting only.I tried to get all the data older than the year/period entered in PARAMETERS, SORT in descending order, and try to delete duplicates, but the number of records is too large, so I get a short dump in the SELECT statement.

Above, thank you.

Sato