Skip to content

Tag: sql

Use average of values in “where” clause

I want to select the top x value from a query where the average of valid values for a particular field is above 10. Why is this throwing an error? Answer Your code is throwing an error because avg() is an aggregation function and cannot be in the where clause. What you want seem to want is apply: The subquery

Remove text after a codeword

I have a list of company names that have been sent with their added company numbers. How can I remove these company numbers (of different length) in SQL? “Limited” if in the name needs to be …