I have 300 records in my database and my structure is something like this
State values
Queensland 4554
Queensland 2343
Queensland 9890
NSW 1333
I want to retrieve all the records with state name Queensland and I want to sum all the records with field name values and the sum to be divided with the number of records (count) with state name.
Can anybody help me out with the syntax to achieve this?
I need something the output to be 5595.66 (i.e. (4454+2343+9890)/3)
OR
As a sidenote, the columnName
valuesis a Reserved keyword. Escape it by a delimiter depending on the RDBMS you are using. Like (backtick) MySQL, (brackets) SQL Server, etc….