Skip to content
Advertisement

How to Update the column from another table having minimum value?

Consider table Tax_Details with below details. In this table, each and every Tax_code should have unique Frequency

Consider another table Freq-Details with Below details. In this table, a Tax_code may have multiple frequency

Consider 3rd table Frequency_Sequence with details. In this table, each and every frequency have some sequence.

I want to update [Frequency] column in Tax_Details table with Frequency from Freq-Details table and the Sequence of frequency should be minimum. My output should be like this

Please help to get this. Thanks in advance.

Advertisement

Answer

You can return the results you want using conditional aggregation:

You can express this in an update as:

Both of these are standard SQL and will work in most databases. However, the syntax might differ slightly in any given database.

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