Railways Exam  >  Railways Questions  >   Which of the following is incorrect SQL?a)Se... Start Learning for Free
Which of the following is incorrect SQL?
  • a)
    Select max(marks) from student
  • b)
    Select sum(marks) from student
  • c)
    Select max(marks1, marks2) from student
  • d)
    Select sum(marks1, marks2) from student
Correct answer is option 'D'. Can you explain this answer?
Verified Answer
Which of the following is incorrect SQL?a)Select max(marks) from stud...
Aggregate functions are functions that take a collection (a set or multiset) of values as input and return a single value.
The input to sum and avg must be a collection of numbers, but the other operators can operate on collections of non-numeric data types, such as strings.
Sum function cannot work on two columns.
View all questions of this test
Most Upvoted Answer
Which of the following is incorrect SQL?a)Select max(marks) from stud...
Incorrect SQL Statement: Select sum(marks1, marks2) from student

Explanation:
The SQL statement mentioned in option 'D' is incorrect. Let's understand why it is incorrect:

1. SELECT Statement:
The SELECT statement is used to retrieve data from one or more tables in a database. It is followed by a list of columns or expressions to be retrieved.

2. SUM Function:
The SUM function is used to calculate the sum of a column's values. It takes a column name as its argument and returns the sum of all the values in that column.

3. MAX Function:
The MAX function is used to retrieve the maximum value from a column. It takes a column name as its argument and returns the maximum value in that column.

4. Incorrect Usage of Functions:
The incorrect SQL statement mentioned in option 'D' is "Select sum(marks1, marks2) from student". This statement tries to calculate the sum of two columns (marks1 and marks2) using the SUM function. However, the SUM function in SQL is designed to work with a single column, not multiple columns.

5. Correct Usage:
To calculate the sum of multiple columns, you need to use the '+' operator to add the values of those columns together. Here's the correct SQL statement to calculate the sum of marks1 and marks2:

SELECT marks1 + marks2 AS total_marks FROM student

This statement will retrieve the sum of marks1 and marks2 as total_marks from the student table.

Conclusion:
In SQL, the correct syntax is crucial for the accurate retrieval and manipulation of data. The incorrect SQL statement mentioned in option 'D' violates the syntax rules of SQL as it tries to use the SUM function with multiple columns. The correct way to calculate the sum of multiple columns is to use the '+' operator to add the values together.
Explore Courses for Railways exam
Which of the following is incorrect SQL?a)Select max(marks) from studentb)Select sum(marks) from studentc)Select max(marks1, marks2) from studentd)Select sum(marks1, marks2) from studentCorrect answer is option 'D'. Can you explain this answer?
Question Description
Which of the following is incorrect SQL?a)Select max(marks) from studentb)Select sum(marks) from studentc)Select max(marks1, marks2) from studentd)Select sum(marks1, marks2) from studentCorrect answer is option 'D'. Can you explain this answer? for Railways 2024 is part of Railways preparation. The Question and answers have been prepared according to the Railways exam syllabus. Information about Which of the following is incorrect SQL?a)Select max(marks) from studentb)Select sum(marks) from studentc)Select max(marks1, marks2) from studentd)Select sum(marks1, marks2) from studentCorrect answer is option 'D'. Can you explain this answer? covers all topics & solutions for Railways 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Which of the following is incorrect SQL?a)Select max(marks) from studentb)Select sum(marks) from studentc)Select max(marks1, marks2) from studentd)Select sum(marks1, marks2) from studentCorrect answer is option 'D'. Can you explain this answer?.
Solutions for Which of the following is incorrect SQL?a)Select max(marks) from studentb)Select sum(marks) from studentc)Select max(marks1, marks2) from studentd)Select sum(marks1, marks2) from studentCorrect answer is option 'D'. Can you explain this answer? in English & in Hindi are available as part of our courses for Railways. Download more important topics, notes, lectures and mock test series for Railways Exam by signing up for free.
Here you can find the meaning of Which of the following is incorrect SQL?a)Select max(marks) from studentb)Select sum(marks) from studentc)Select max(marks1, marks2) from studentd)Select sum(marks1, marks2) from studentCorrect answer is option 'D'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Which of the following is incorrect SQL?a)Select max(marks) from studentb)Select sum(marks) from studentc)Select max(marks1, marks2) from studentd)Select sum(marks1, marks2) from studentCorrect answer is option 'D'. Can you explain this answer?, a detailed solution for Which of the following is incorrect SQL?a)Select max(marks) from studentb)Select sum(marks) from studentc)Select max(marks1, marks2) from studentd)Select sum(marks1, marks2) from studentCorrect answer is option 'D'. Can you explain this answer? has been provided alongside types of Which of the following is incorrect SQL?a)Select max(marks) from studentb)Select sum(marks) from studentc)Select max(marks1, marks2) from studentd)Select sum(marks1, marks2) from studentCorrect answer is option 'D'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Which of the following is incorrect SQL?a)Select max(marks) from studentb)Select sum(marks) from studentc)Select max(marks1, marks2) from studentd)Select sum(marks1, marks2) from studentCorrect answer is option 'D'. Can you explain this answer? tests, examples and also practice Railways tests.
Explore Courses for Railways exam

Top Courses for Railways

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev