Use of single quotes in select query while aggregating data?
What is the difference between
- select avg('orders') and
- select avg(orders) in MySQL?
Also, are both correct in syntax?
If yes, when do you use each of them?
The AVG() function returns the average value of a numeric column.
avg('orders') always return 0 because avg of string ('orders') is zero
Avg(orders) return average of column orders
Avg(`orders`) or Avg(orders) are correct syntax