I am a beginner SQL in need of some advice. What is the most efficient (quick request) way to do the following -
Select all columns from the table after -
-Use "Group by" based on the unique values contained in two columns: "top_line_id" and "external_reference".
-Selection of one record from each group based on the maximum or minimum value (no matter which one) is contained in another field, such as support_id.
Someone from my team has provided a request below, but I cannot get it to work. I get an error "invalid relational operator" when I try to execute it.
Select * from STAGE.SFS_GH_R3_IB_ENTLMNT_CONTACTS Where support_id, external_reference, top_line_id in ( select max(support_id), external_reference, top_line_id from STAGE.SFS_GH_R3_IB_ENTLMNT_CONTACTS )
One more thing - the columns in which we execute the By group contain null values in some records. We would like to exclude from the request.
Any help you can provide is greatly appreciated.
source share