Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a table with Code and Date, where multiple Dates for any Code.
I want to load Code, Date but only where Date is the maximum Date for that Code.
Code | Date |
---|---|
A | Jan 1 |
A | Apr 1 |
A | Aug 20 |
B | Feb 2 |
B | Feb 3 |
So for above, it will load
Code | Date |
---|---|
A | Aug 20|
B | Feb 3 |
Any ideas please?
You can do it in one step:
Table:
LOAD
Code,
Max(Date) as Date
FROM ...
GROUP BY Code;
If you have more fields in that table, you will need a second step:
Left Join (Table)
Load
Code,
Date,
...
From...
This will only join the data of Codes with Max DAte.
You will need to create a temp table containing the max value, you then use the PEEK function to get the value to use later
You can do it in one step:
Table:
LOAD
Code,
Max(Date) as Date
FROM ...
GROUP BY Code;
If you have more fields in that table, you will need a second step:
Left Join (Table)
Load
Code,
Date,
...
From...
This will only join the data of Codes with Max DAte.