L
L
Lileika2015-08-06 10:56:50
SQL
Lileika, 2015-08-06 10:56:50

Which of the queries will return 3 sql records?

Given table nums with data:
id | num
---+----
1 | 1
2 | null
3 | 2
2 | null
3 | 5
3 | 7
Which of the following queries will return exactly 3 records from this table:
1. SELECT 3 FROM nums;
2. SELECT id FROM nums;
3. SELECT num FROM nums WHERE num IS NOT NULL;
4. SELECT DISTINCT id FROM nums;
5. SELECT COUNT(DISTINCT id) FROM nums;
6. SELECT * FROM nums WHERE id <> num;
7. SELECT DISTINCT id FROM nums WHERE num IS NOT NULL;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zahar Budovskih, 2015-08-06
@Lileika

4. SELECT DISTINCT id FROM nums;
--------------
id
1
2
3
6. SELECT * FROM nums WHERE id <> num;
id | num
------------
3 | 2
3 | 5
3 | 7

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question