Reputation: 59
In the SELECT clause I have SELECT isnull(client,'')+'-'+isnull(supplier,'')
, is it ok to write GROUP BY client,supplier
, or should I mandatorily write GROUP BY isnull(client,'')+'-'+isnull(supplier,'')
?
Upvotes: 0
Views: 489
Reputation: 13
You can directly say group by client, supplier
Please see sample data and result after running query.
Upvotes: 0
Reputation: 4035
Just list the column names. You can verify this by executing it, and also look at execution plans to verify index usage.
GROUP BY client,supplier
Upvotes: 0
Reputation: 6157
It's better to GROUP BY client, supplier
. That way if there's any indexer available it can be used. While the other solution also works it would require a whole table scan in every case.
Upvotes: 1