Skip to content
Advertisement

How to get the Exact Batch ID from stock table on the basis of Expiry Date?

I want to get the batch id from stock table on the basic of fifo expiry date. How to get it. I write a query it give the exact batch but batch id not accurate. Basically I want to Fetch the batch is of the product which expired first

The Stock Table is Like as

I write this Query

Current Output

Expected Output:

Advertisement

Answer

You are using aggregate min function it gives you wrong output.you can use order by function for sorting.

DEMO

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