Skip to content
Advertisement

How to determine all details should go to first line item if we have multiple duplicate dates?

1)I have four fields like material no, item no, date, quantity.

Input:

Requirement is we need to consider date as reference

2) If date is repeated twice or n number of times , the output should goes to first item with adding quantity.

Output:

Advertisement

Answer

It seems you need to run the following SQL query:

JDBC Example:

Update

If MySQL 8 is used it should be possible to use its FIRST_VALUE function to locate first item in a group.

Otherwise, the query may be rewritten to use subquery with LIMIT 1 for item:

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