Skip to content
Advertisement

How can I extract both column from View named “Max_part_supplied’? [closed]

I have created a view named ‘Max_part_supplied’ which consists of two column as Number_of_parts and Supplier_name. I am trying to access the Supplier_name who supplies maximum number of parts, as

This is the view Max_part_supplied

But I am getting error message as

Msg 8120,Level 16,State 1,line 84 Column Max_part_supplied.Supplier_name is invalid in the select list because it is not containted in either aggregate function or the GROUP BY clause.

Advertisement

Answer

It looks like your view already has the max per supplier, you just want the maximum of these?

If you want all suppliers in the event two or more have the same max, use top (1) with ties

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