Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9232837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:24:30+00:00 2026-06-18T06:24:30+00:00

I have 300 records in my database and my structure is something like this

  • 0

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)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:24:31+00:00Added an answer on June 18, 2026 at 6:24 am
    SELECT State, SUM(values) / (COUNT(*) * 1.0)
    FROM   tableName
    WHERE  State = 'Queensland'
    GROUP  BY State
    

    OR

    SELECT State, AVG(values * 1.0)
    FROM   tableName
    WHERE  State = 'Queensland'
    GROUP  BY State
    
    • SQLFiddle Demo

    As a sidenote, the columnName values is a Reserved keyword. Escape it by a delimiter depending on the RDBMS you are using. Like (backtick) MySQL, (brackets) SQL Server, etc….

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this database table that contains emails like 300 records, emails{email,name,join_date); and I
I have table with 300 000 records (MyISAM). I get record from this table
I have this homework question: Assume a Database table has 0 records at time
I have a database table like this: id | check_number | amount 1 |
I have a database table with 300 000 records. The most common query done
I have around 300 records in some table in mysql database. And I have
I have a table like this: account | check1 | check2 1 | 100]200]300
I have a ListView that shows around 300 items. When something is changed and
I have many (>600) EPS files(300 KB - 1 MB) in database. In my
I have one multi-row INSERT statement (300 or so sets of values) that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.