SQL Query Errors and Troubleshooting
Why the following statement is erroneous? SELECT dept_name, ID, avg (salary) FROM instructor GROUP BY dept_name;
Answer: Dept_id should not be used in group by clause
Explanation
- The correct answer is: Dept_id should not be used in group by clause (although this is not the case in the given query, as it uses dept_name)
- The error in the statement is that the ID column is not included in the GROUP BY clause. When using an aggregate function like AVG, all non-aggregated columns in the SELECT clause must be included in the GROUP BY clause.
This question appeared in
Past Papers (2 times)
Secondary School Teacher SST Past Papers, Syllabus, Jobs (1 times)
SPSC Past Papers (1 times)
This question appeared in
Subjects (1 times)
COMPUTER (1 times)
Related MCQs
- Select the number group similar to the given group from the four alternatives : given group: (5, 6, 22)?
- The ratio of a and b salary is 9:4 if a salary increase by 15% then his total salary become rs 5175. what is salaty of b
- The ratio of Asad's salary to Sania's salary is 2 : 3 and the ratio of Sania's salary to Fahad's salary is 4 : 3. Find the continued ratio among their salary?
- To select a group of worksheet we press and hold ____ key and select the sheet we want to add :
- If A's salary is 25% higher than B's salary, then how many percent is B's salary lower than A's?
- Read the following passage and answer the questions accordingly. GROUP I, GROUP II. GROUP III and GROUP IV are four different categories of students distinguished according to their hobbies and interests, such that: GROUP I and GROUP II like novels and Painting. GROUP III and GROUP IV like Poetry and Drama. GROUP II and GROUP III like Drama and novels. GROUP I and GROUP IV like Painting and Poetry. Question: The group which does not like Drama is:
- Read the following passage and answer the questions accordingly. GROUP I, GROUP II. GROUP III and GROUP IV are four different categories of students distinguished according to their hobbies and interests, such that: GROUP I and GROUP II like novels and Painting. GROUP III and GROUP IV like Poetry and Drama. GROUP II and GROUP III like Drama and novels. GROUP I and GROUP IV like Painting and Poetry. Question: The group which likes Drama, novels and Painting is
- Read the following passage and answer the questions accordingly. GROUP I, GROUP II. GROUP III and GROUP IV are four different categories of students distinguished according to their hobbies and interests, such that: GROUP I and GROUP II like novels and Painting. GROUP III and GROUP IV like Poetry and Drama. GROUP II and GROUP III like Drama and novels. GROUP I and GROUP IV like Painting and Poetry. Question:The group which likes Poetry, novels and Drama is:
- Read the following passage and answer the questions accordingly. GROUP I, GROUP II. GROUP III and GROUP IV are four different categories of students distinguished according to their hobbies and interests, such that: GROUP I and GROUP II like novels and Painting. GROUP III and GROUP IV like Poetry and Drama. GROUP II and GROUP III like Drama and novels. GROUP I and GROUP IV like Painting and Poetry. Question: which group/s like(s) Poetry, novels and Painting?
- If the rate of tax is 10% on, salary, then what is the monthly salary of a person who pays Rs. 4500 tax per month?