Here is my T-SQL query
SELECT
ProductID,
VendorID,
ProductName= MAX(ProductName),
VendorName = MAX(VendorName),
IsActive = MAX(IsActive) # This brings error
FROM ProductVendorAssoc
GROUP BY
ProductID,
VendorID
I want to apply GROUP BY
only for the ProductID and VendorID
fields, but need to populate the ProductID, VendorID, ProductName, VendorName, IsActive
fields.
Here I used the agreggate function MAX(ProductName)
to avoid ProductName
in the group by list.
But the same trick is not working for BIT
columns as operand data type bit is invalid for max operator.
How can i include BIT
type column in SELEC
T part with out including it on the GROUP BY
?
Update.
What should I need to do if i need to include an INT
column like UserID
in SELECT
in the same way