If you put an rtrim in the SELECT and also again in the GROUP BY, is this inefficient because its rtriming twice, one in the select and one in the group by? eg...
SELECT
rtrim(people.FORENAME1)+ ' ' + rtrim(people.SURNAME)AS Full_Name,
FROM
my table
GROUP BY
rtrim(people.FORENAME1)+ ' ' + rtrim(people.SURNAME)
It's probably only performing the function once, but it's inefficient since it's non SARGable.
Since you are applying a function, the optimizer can't use any existing indexes that refer to those fields. It doesn't know the results of the function(s) until they are run, so it needs to process each and every row in the table.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.