Sql query for aggregate function for a record. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Sql query for aggregate function for a record.

Name sub1 sub2 sub3 max/min Ajay 80 78 90 null Vinay 78 65 89 null Rita 70 89 75 null Here i want to calculate maximum,minimum of sub1, sub2, sub3 for each record. Aggregate function works along columns not on records. So anyone help to write sql query to calculate for each records.

26th May 2021, 11:36 AM
Kavya N
Kavya N - avatar
2 Answers
26th May 2021, 11:47 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
In some databases there are LEAST and GREATEST functions with which you could do this: LEAST(sub1,sub2,sub3) These functions return the min/max from a list of values
1st Jun 2021, 10:48 PM
Monica Garcia
Monica Garcia - avatar