Skip to content
Advertisement

Get several data from SQL query based on different conditions

I have the following code:

And I get as a result one total sold of one client. But I want to get one for each contenant for each client. (But it still need to be the last one by date)

I’m getting as a result: sql query result And I want to get several result like that such as:

sold_total_client is what the client as after a shipment, there is several shipment and the sold is updated at every move, so the last one by date is the actual sold. So I have to get the last move of every contenant of every client.

Advertisement

Answer

You could try using a subquery for max_date group by client_id, contenant_id

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement