I am working with a data base and I need to show the people who are older than the age average in a city comparing their age against that average. My code shows the people who is older than the average….but I can’t show the average of all the people (it’s allways the same number) in each line. I need
Tag: average
How to get mean of exams by client with 2 tables?
I know a little bit of sql, only the basic, now I need to create a analytic query but can’t do this yet. I have 2 tables on my db oracle, client and exams: I am tried a lot of ways to get the mean of exams by client, but no success yet.4 The result expected is: exams = 13
Query to find the count of total IDs, and IDs having null in any column and the percentage of the two (i.e. Count of ID having null /total ID count)
There are two tables. Tables A has following structure ID Flag Name 1X 1 Y 2Y 0 Null 3Z 1 Null 4A 1 Y Table B has the following structure B_ID City State 1X Y Null 2Y Null Null 3Z Null Y 4A Y Y I want to get the count of all the IDs and the count of IDs
Get historical average and count of a value where a date could exist more than once
I have a table with multiple equal date entries and a value. I need a table that calculates the historical value and the count of entries per date. I want to use the data to create some charts in gnuplot/etc later. Raw data: Output should be: If it is not possible to calculate two different columns, I would be fine
How to create a derived attribute column in sql which is sum of other two existing columns
I want to have a column selling_price which is sum of scost and dcost. Answer You can use MySQL generated columns for it. Reference Doc
How to find the average time? SQL Server 2017
I have a request like this: I need to find the average time for each status. For example, add up the time of all statuses 2 and divide by their number. As a result, get something like 2 days 5 hours. How to fix my request to make belt operations possible? Answer Taking your limited example data, something like this
Find the average over the n last purchases, for every user in the table using SQL
I have a SQLite db with two tables: users userID field1 field2 field3 field4 1 2 3 purchases purchaseID userID price timestamp 1 2 70 5166323 2 1 30 6543654 3 1 100 5456434 4 2 30 5846541 5 2 40 9635322 6 1 50 2541541 I want to write an SQL query that returns a table userID field1 field2
Query to Identify Above Average Sales for Company
I am trying to find the employees who have sales figures that are above the average sales totals for a particular company. I am using Microsoft SQL Server, and here is what I have so far: However, my query returns nothing. Is this the correct way to write something like this? What could I do to simplify things? Answer If
Mode average – need help for calculation in SQL Server
I need to calculate the mode average by clinic. Test data as follows: Clinic Test2 A123 2 A123 3 A123 4 A123 3 A123 3 B123 2 B123 2 B123 2 B123 2 B123 2 B123 4 I can show the mode for all clinics using However, I want the mode per clinic, not all clinics. What I really want
SQL – An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause
If you see the picture below, I only want to see those categories where the average revenue is greater than the overall average. The query that I’m using is below. The very last line is causing the issue. The error that I’m getting is: An aggregate may not appear in the WHERE clause unless it is in a subquery contained