Why the following statement is erroneous? SELECT dept_name, ID, avg (salary) FROM instructor GROUP BY dept_name;
- Dept_id should not be used in group by clause
- Group by clause is not valid in this query
- Avg(salary) should not be selected
- None
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.
Related MCQs
سمورغ نامی سپر کمپیوٹر کس ملک نے تیار کیا ہے؟
- China
- Japan
- Iran
- None of these
اس سوال کو وضاحت کے ساتھ پڑھیں
سی پی یو کے اندر کون سی میموری نصب ہوتی ہے؟
- RAM
- ROM
- Register
- None of these
اس سوال کو وضاحت کے ساتھ پڑھیں
ورلڈ وائیڈ ویب کو رابرٹ کیلِیو کے ساتھ کس نے ایجاد کیا؟
- Tom Burne
- Tim Burner Lee
- Fred Zuckerberg
- Both a and b
اس سوال کو وضاحت کے ساتھ پڑھیں
مصنوعی ذہانت کا بانی کسے کہا جاتا ہے؟
- Mark Zuckerberg
- Alan Turing
- John McCarthy
- Bill Gates
اس سوال کو وضاحت کے ساتھ پڑھیں
کمپیوٹر گرافکس کا بانی کسے کہا جاتا ہے؟
- Charles Babbage
- Alan Turing
- Ivan Sutherland
- None of these