Select Flashcards

1
Q

List ways to get count or records in a table

A

SELECT * FROM table1

SELECT COUNT(*) FROM table1

SELECT rows FROM sysindexes WHERE id = OBJECT_ID(table1) AND indid < 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Write a query to find the names of employees that begin with ‘A’

A

SELECT * FROM Table_name WHERE EmpName like ‘A%’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Write a query to get the third-highest salary of an employee from an employee table

A
SELECT TOP 1 salary
FROM(
SELECT TOP 3 salary
FROM employee_table
ORDER BY salary DESC) AS emp
ORDER BY salary ASC;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly