If an asterisk (*) is placed the select phrase instead of attribute names, it would mean that we want all the attributes at the output. The after the clause refers to the relation from which we want to perform the table name FROM query. The after the clause contains the actual query. The expressions may contain expressions WHERE the following operators: Comparison operators: <, <=, >, >=, =, <> Logical connectives: AND, OR, NOT Simplified operators: BETWEEN AND this some_value some_other_value, NOT BETWEEN AND this some_value some_other_value [These are the substitutes for: AND this <= some_value this >= some_other_value] Q4. From the following table named find out the students (along with their marks) who result, have scored more than 80 marks, and display them in the descending order of their marks. student_name A 55 B 90 C 40 D 80 E 85 F 95 G 82 select from where order by desc; student_name, marks result marks > 80 marks Or, as the table contains only these two fields, we can write: select from where order by desc; * result marks > 80 marks Output: student_name F 95 B 90 E 85 G 82 Q5. From the above table in Q4, we want to find out the top-most 3 students (to give them prizes for obtaining the 1st, 2nd and 3rd places). How would you find them? select student_name from result order by marks desc limit 3; Output: student_name F B E Q6. From the table in Q4, we want to find out the student who stood 2nd. How would you find him? select from order by desc limit 1, 1; student_name result marks Output: student_name B
If an asterisk (*) is placed the select phrase instead of attribute names, it would mean that we want all the attributes at the output. The table name after the FROM clause refers to the relation from which we want to perform the query. The expressions after the WHERE clause contains the actual query. The expressions may contain the following operators: Comparison operators: <, <=, >, >=, =, <> Logical connectives: AND, OR, NOT Simplified operators: this BETWEEN some_value AND some_other_value, this NOT BETWEEN some_value AND some_other_value [These are the substitutes for: this <= some_value AND this >= some_other_value] Q4. From the following table named result, find out the students (along with their marks) who have scored more than 80 marks, and display them in the descending order of their marks. student_name A 55 B 90 C 40 D 80 E 85 F 95 G 82 select student_name, marks from result where marks > 80 order by marks desc; Or, as the table contains only these two fields, we can write: select * from result where marks > 80 order by marks desc; Output: student_name F 95 B 90 E 85 G 82 Q5. From the above table in Q4, we want to find out the top-most 3 students (to give them prizes for obtaining the 1st, 2nd and 3rd places). How would you find them? select student_name from result order by marks desc limit 3; Output: student_name F B E Q6. From the table in Q4, we want to find out the student who stood 2nd. How would you find him? select student_name from result order by marks desc limit 1, 1; Output: student_name B
DBMS_An_Interactive_Tutorial.docx