The first line contains the integer, the size of the matrix (N). The next lines contains the matrix elements separated by a space.
Print one line: Sum of elements from the matrix main diagonal.
2 < N < 100
3
1 2 3
4 5 6
7 8 9
15
The first line contains the integer, the number of students (N). The next lines contains the name and marks obtained by that student separated by a space. The final line contains the name of a particular student previously listed.
2 < N < 100
0 < Marks < 100
Print one line: The average of the marks obtained by the particular student correct to 2 decimal places.
3
Krishna 67 68 69
Arjun 70 98 63
Malika 52 56 60
Malika
56.00
Marks for Malika are {52 56 60} whose average is (52+56+60)/3 is 56.
2
Harsh 25 26.5 28
Anurag 26 28 30
Harsh
26.50
Given the following tables:
sql> SELECT * FROM runners;
+----+--------------+
| id | name |
+----+--------------+
| 1 | John Doe |
| 2 | Jane Doe |
| 3 | Alice Jones |
| 4 | Bobby Louis |
| 5 | Lisa Romero |
+----+--------------+
+----+----------------+-----------+
| id | event | winner_id |
+----+----------------+-----------+
| 1 | 100 meter dash | 2 |
| 2 | 500 meter dash | 3 |
| 3 | cross-country | 2 |
| 4 | triathalon | NULL |
+----+----------------+-----------+
What will be the result of the query below?
SELECT * FROM runners WHERE id NOT IN (SELECT winner_id FROM races)
Explain your answer and also provide an alternative version of this query that will avoid the issue that it exposes.
Assume a schema of Emp ( Id, Name, DeptId ) , Dept ( Id, Name). If there are 10 records in the Emp table and 5 records in the Dept table, how many rows will be displayed in the result of the following SQL query:
Select * From Emp, Dept
Explain your answer.
Write a query how do you copy data from one table to another table?
You have a table:
create table test (name VARCHAR(20), email VARCHAR(20));
How to find a duplicate record?
- Duplicate records with one field
- Duplicate records with more than one field (both name and email).