0

While working on a oracle SQL , noticed that adding a column to the selected columns increases the total rows in the result. The query is using multiple subqueries declared using WITH. The join in the final query is a left join. Why is the row count getting impacted?

2
  • 1
    Are you using the distinct keyword? Commented Jul 4, 2017 at 18:59
  • yes. the select has a distinct keyword. Commented Jul 4, 2017 at 19:00

1 Answer 1

4

The only way I can think of to increase the number of result rows by adding a column to the SELECT clause is when using SELECT DISTINCT.

SELECT DISTINCT removes duplicates from the results, so

 col1 col2 a b a b a c a c 

becomes

 col1 col2 a b a c 

When adding a column

 col1 col2 col3 a b d a b e a c f a c f 

becomes

 col1 col2 col3 a b d a b e a c f 

for instance, which is one row more than before.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.