Write a query to display the coursename of the courses having the coursefees above average fees of all the courses. Display the records sorted in ascending order based on coursename.Note:1. Display only the coursename of the courses having the coursefees above average fees of all the courses.2. Order by is mandatory.Sample Output:
Question
Write a query to display the coursename of the courses having the coursefees above average fees of all the courses. Display the records sorted in ascending order based on coursename.Note:1. Display only the coursename of the courses having the coursefees above average fees of all the courses.2. Order by is mandatory.Sample Output:
Solution
Assuming you are using SQL and you have a table named "courses" with columns "coursename" and "coursefees", here is a step-by-step guide on how to write the query:
- First, you need to calculate the average course fee. You can do this using the AVG() function in SQL. The query would look like this:
SELECT AVG(coursefees) FROM courses;
- Next, you want to select the courses that have a fee above this average. You can do this by using a subquery in the WHERE clause of your SQL statement. The subquery will return the average course fee, and the WHERE clause will filter out the courses that have a fee below this. The query would look like this:
SELECT coursename
FROM courses
WHERE coursefees > (SELECT AVG(coursefees) FROM courses);
- Finally, you want to sort the results in ascending order based on the course name. You can do this using the ORDER BY clause. The final query would look like this:
SELECT coursename
FROM courses
WHERE coursefees > (SELECT AVG(coursefees) FROM courses)
ORDER BY coursename ASC;
This query will return the names of the courses that have a fee above the average, sorted in ascending order.
Similar Questions
Write a query to display the coursename, coursecategory, coursefees and courseduration of the courses whose batch strength is greater than or equal to 10 and month of batch start date is 'February'. Display the records sorted in ascending order based on coursename.Note:1. Display only the coursename, coursecategory, coursefees and courseduration of the courses whose batch strength is greater than or equal to 10 and month of batch start date is 'February'2. Tables involved are course and batch3. Order by is mandatory.Sample Output :
Write a query to display the coursename of the courses whose month of batch start date is between 'February' and 'July'. Display the records sorted in ascending order based on coursename.
Given 3 tables, students(id, name) , courses(id, name) , grades(id, course_id, student_id, grade), find the top 100 students based on their average grades sorted descendingly by the average grade and in case multiple students have the same average grade, sort them lexicographically in ascending order by their names. Your query should output a table with the following columns (name, average_grade).
Write a query to display the student qualification(squal) and the total number of students based on their qualifications. Give an alias name as ‘totalStud’. Display only the squal having the totalStud count less than 8. Display the records sorted in ascending order based on squal.
Choose the query to display names of the department in the college ordered in department_name in ascending order.select department_name from Department order by department_name asc;select department_name from Department order by name asc;select name from Department order by name;None of the listed optionsReview Answer
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.