New Year Sale 2026! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

PostgreSQL PGCES-02 Exam - Topic 8 Question 30 Discussion

Actual exam question for PostgreSQL's PGCES-02 exam
Question #: 30
Topic #: 8
[All PGCES-02 Questions]

The tables "s1" and "s2" are defined below. The column "id" for tables "s1" and "s2" is of INTEGER type. The column "enable" for table "s1" is of BOOLEAN type, and the column "name" for table "s2" is of TEXT type.

s1: id |

enable

----+--------

1 | t 2 | f

s2: id |

name ----

+------ 1 |

post 2 |

gre 3 |

SQL

The following SQL was executed. Select the correct number of rows in the result. SELECT * FROM s2 WHERE id IN (SELECT id FROM s1);

Show Suggested Answer Hide Answer
Suggested Answer: A

Contribute your Thoughts:

0/2000 characters
Tennie
4 months ago
Seems like a straightforward query, but I’m surprised by the result!
upvoted 0 times
...
Garry
4 months ago
I thought it would be 1 row, but I see the logic now.
upvoted 0 times
...
Marvel
4 months ago
Wait, why would it return 3?
upvoted 0 times
...
Rosio
4 months ago
Definitely 2 rows!
upvoted 0 times
...
Veronique
4 months ago
The subquery returns ids 1 and 2 from s1.
upvoted 0 times
...
Marisha
5 months ago
I might be confused, but I feel like the result could also be 1 row if there's something I'm missing about the IDs.
upvoted 0 times
...
Brittni
5 months ago
If I recall correctly, the IDs in s1 are 1 and 2, so that should match with s2 and give us 2 rows.
upvoted 0 times
...
Benedict
5 months ago
I'm not entirely sure, but I remember something similar where the subquery only returned the IDs that exist in both tables.
upvoted 0 times
...
Boris
5 months ago
I think the query will return 2 rows because there are two matching IDs in table s1.
upvoted 0 times
...
Boris
5 months ago
Definitely Benchmarking. It's the classic tool for analyzing how your organization stacks up against the competition and identifying areas for improvement.
upvoted 0 times
...
Kris
5 months ago
This seems pretty straightforward. The origin attribute is set to incomplete when using the import-route command, so the answer must be TRUE.
upvoted 0 times
...
Jerry
5 months ago
This seems straightforward. The loop is displaying the last three values, so the answer must be A.
upvoted 0 times
...
Tanja
9 months ago
Ah, the old 'SQL query with a twist' trick, eh? I bet the exam writers had a field day coming up with this one. Imagine if the tables were named 'table1' and 'table2' instead - the confusion would be off the charts! But hey, at least they kept the column names simple. 'id' and 'name' - no fancy stuff here. Just good old-fashioned SQL goodness.
upvoted 0 times
...
Desmond
9 months ago
This is a classic SQL query, but with a twist! I love these types of questions. Let me break it down... The 's1' table has 2 rows, and the 's2' table has 3 rows. The IN clause will only return the rows from 's2' that have an id matching the ids in 's1'. So, the correct answer is B) 2 rows. Easy peasy!
upvoted 0 times
Sylvia
8 months ago
Exactly, that's why the correct answer is 2 rows.
upvoted 0 times
...
Hortencia
9 months ago
So, it will only return 'post' and 'gre' from 's2'.
upvoted 0 times
...
Goldie
9 months ago
Yeah, I agree. The query will only return the rows from 's2' that have matching ids in 's1'.
upvoted 0 times
...
Lourdes
9 months ago
I think the answer is B) 2 rows.
upvoted 0 times
...
...
Rhea
9 months ago
Hmm, this one's a bit tricky. I'm going to have to carefully examine the data in the tables to figure this out. Ah, I see now! There are 2 rows in 's1' with ids 1 and 2, and the 's2' table has 3 rows with ids 1, 2, and 3. The IN clause will only return the matching rows, so the correct answer is B) 2 rows.
upvoted 0 times
...
Annice
9 months ago
Ah, a classic SQL query with a subquery! I just love these types of questions. Let me think this through... The 's1' table has 2 rows, and the 's2' table has 3 rows. The IN clause will only return the rows from 's2' that have an id matching the ids in 's1'. So, the correct answer is B) 2 rows.
upvoted 0 times
Sheridan
8 months ago
No, it's definitely B) 2 rows.
upvoted 0 times
...
Yvonne
8 months ago
I think it's C) 3 rows.
upvoted 0 times
...
Sol
9 months ago
I agree, the answer is B) 2 rows.
upvoted 0 times
...
...
Virgilio
11 months ago
The key to this question is understanding the relationship between the two tables. Since the 'id' column in both tables is of INTEGER type, we can use the IN clause to find the matching ids. Given the data in the tables, there are 2 rows in 's1' table, and 3 rows in 's2' table that have matching ids. Therefore, the correct answer is B) 2 rows.
upvoted 0 times
Mohammad
9 months ago
Therefore, the correct answer is B) 2 rows.
upvoted 0 times
...
Soledad
9 months ago
So, there are 2 rows in 's1' and 3 rows in 's2' with matching ids.
upvoted 0 times
...
Linwood
10 months ago
Yes, you're right. The correct answer is B) 2 rows.
upvoted 0 times
...
Noe
10 months ago
I think the answer is B) 2 rows.
upvoted 0 times
...
Asha
10 months ago
I agree, the key is to use the IN clause to find matching ids.
upvoted 0 times
...
Salena
10 months ago
I think the answer is B) 2 rows.
upvoted 0 times
...
...
Vicente
11 months ago
I'm not sure, but I think the answer might be C) 3 rows.
upvoted 0 times
...
Evette
11 months ago
I agree with Nancey, because there are 2 matching ids in s1 and s2.
upvoted 0 times
...
Nancey
11 months ago
I think the answer is B) 2 rows.
upvoted 0 times
...

Save Cancel