I have written the following sql query:
SELECT
*
FROM CSVDatabase.dbo.sales_info
GROUP BY Company HAVING AVG(Sales)
Its based on the following dataset
However, I get the following error:
1 An expression of non-boolean type specified in a context where a condition is expected, near 'SET'.
I'm trying to get the mean across the whole dataset.
I have also written a python script that sets out to accomplish the same results as that in the sql script above, as follows:
df.groupBy('Company').mean().show()
The python script returns the results I would like to see from sql as shown below:
Can someone let me know where I'm going wrong with the sql script?
HAVING
keyword in SQL is not used toSELECT
valuesHAVING AVG(Sales)
. Looks like you missing condition likeHAVING AVG(Sales)>value