Interview Basic Question for SQL

1) The Difference between Count and Count (*)?
Count:-
Counts the number of non-null values.
Count (*):-
Counts the number of rows in the table, including null values and duplicates.
2) What is a ROWID?
ROWID is the logical address of a row, and it is unique within the database.
3) What is a UNIQUE KEY?
A UNIQUE KEY is one or more columns that must be unique for each row of the table.
4) What is a PRIMARY KEY?
The PRIMARY KEY is the column(s) used to uniquely identify each row of a table.
5) Can Primary key is a Foreign Key on the same table?
Yes
6) Write a query to select the 5th highest salary from a table.
SELECT min (salary) AS high5 FROM employee WHERE salary IN (SELECT DISTINCT TOP 5 salary FROM orders ORDER BY salary DESC)

No comments:

Post a Comment

Plz Share your comments...