Skip to content

Tag: mysql

How to perform LEFT JOIN with condition

I want to perform something like this Answer If I understand correctly, you want to conditionally join to a table. I would recommend two left joins as in: Because it is the same table, you could also use or in the on clause: However, or in an on clause usually kills performance.

get 2nd highest sum in mysql

i have table emp : emp_id quantity 1001 21 1001 10 1002 3 1002 5 1004 4 1004 5 1004 8 i want to get the id having 2nd highest sum so expected output is 1004 17 let me know how can …

Query returns duplicate values [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question The query below is showing some duplicate and wrong values: The output should look like this:…