Dear Query experts,
In the below example I am able to get the correct answer, but I have the feeling my method is too complex
A very simplified example is the results of a UNION query (records are coming from different tables)
Query1
Position ; DateTime ; Value
242 ; 26-12-2019 10:00 ; 1
241 ; 25-12-2019 07:00 ; 2
243 ; 26-12-2019 07:00 ; 3
242 ; 26-12-2019 07:00 ; 6
242 ; 26-12-2019 04:45 ; 2
241 ; 26-12-2019 11:00 ; 8
243 ; 25-12-2019 07:00 ; 4
The results should be the Max from datetime group by position
241 ; 26-12-2019 11:00 ; 8
242 ; 26-12-2019 10:00 ; 1
243 ; 26-12-2019 07:00 ; 3
I do this by a second query SELECT max(datetime) from "query1" group by position and link the result to query1 (pos to pos and datetime to datetime)
Are there methods to simplify this?
Thanks in advance.
Ben
In the below example I am able to get the correct answer, but I have the feeling my method is too complex
A very simplified example is the results of a UNION query (records are coming from different tables)
Query1
Position ; DateTime ; Value
242 ; 26-12-2019 10:00 ; 1
241 ; 25-12-2019 07:00 ; 2
243 ; 26-12-2019 07:00 ; 3
242 ; 26-12-2019 07:00 ; 6
242 ; 26-12-2019 04:45 ; 2
241 ; 26-12-2019 11:00 ; 8
243 ; 25-12-2019 07:00 ; 4
The results should be the Max from datetime group by position
241 ; 26-12-2019 11:00 ; 8
242 ; 26-12-2019 10:00 ; 1
243 ; 26-12-2019 07:00 ; 3
I do this by a second query SELECT max(datetime) from "query1" group by position and link the result to query1 (pos to pos and datetime to datetime)
Are there methods to simplify this?
Thanks in advance.
Ben