Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Write Mysql query with average age counting
Try the following
select
ReportsTo,
count(*) as Members,
avg(age) as Average_Age
from yourTable
where ReportsTo is not null
group by
ReportsTo
This is actually quite easy. This may work for you!
SELECT ReportsTo, COUNT(Members) as Members, AVG(Age) as average
FROM table
GROUP BY ReportsTo
ORDER BY ReportsTo
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
here is my query
SELECT distinct(DESIG_NAME)
FROM employees
WHERE GRADE like ("L0007", "L0008", "L0009");
I want to find grade of employee in one single statement
grade are level e.g., level7, level8, etc something like this
DISTINCT is not a function, and also you want WHERE IN (...):
SELECT DISTINCT DESIG_NAME
FROM employees
WHERE GRADE IN ('L0007', 'L0008', 'L0009');
SELECT distinct(DESIG_NAME) FROM employees where GRADE like 'L0007' or like 'L0008' or like 'L0009'
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Here is the MySQL code
select id, name, code, batch_id from subjects where batch_id=18;
In this query i want name to be subject name during the execution. So this is the whole problem.
Do you want a column alias in the resultset?
select id, name as subject_name, code, batch_id
from subjects
where batch_id = 18
This changes the name of column name to subject_name in the result of the query.
I don't see what your question has to do with the where clause.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have a simple entry in the oracle, there are 3 columns, date, API name and status. I want that in the answer I had not all history, and only the last on each of Names of API (only 7). I will be grateful for your help. I know that asked of the very difficult but I'm just new to oracle.
select l.log_date,l.job_name,l.status from user_scheduler_job_log l
could be you want the related status for name and last log_date
select u.job_name, u.status, t.max_date
from user_scheduler_job_log u
INNER JOIN(
select MAX(l.log_date) max_date, l.job_name
from user_scheduler_job_log l
GROUP BY l.job_name
) t on t.max_date = u.log_date
AND t.job_name = u.job_name
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
SELECT location,special,price FROM `tickets`
WHERE event = 'food' GROUP BY location
I think you want, (assuming its mysql) the following:
SELECT location, ANY_VALUE(special) special, ANY_VALUE(price) price
FROM tickets
WHERE event='food'
GROUP BY location ;
ANY_VALUE is strange aggregate function out of normal db standards that returns one of the values arbitarily.
If you wish to not have duplicate results in your rows you can choose only distinct result set.
SELECT DISTINCT location,special,price FROM tickets WHERE event = 'food' GROUP BY location
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
So I have a table for biddings, you can win the bidding by posting the lowest unique bid. So if 2 people place a bet of $1, none of them win, if 1 person places a bet of $2, this guy wins. But how can I check this in MySQL?
Assume your table has the bid value stored in the field name bet, then below is a worked solution:
SELECT * FROM YourTableName
WHERE bet = (SELECT MIN(bet) FROM YourTableName)
GROUP BY bet
HAVING COUNT(*) = 1;