Ajay Chowdary Kandula
asked on
Difference in the number of rows returned
select distinct col1 , col2 from table;
//75048 Records Returned
with temp as (select distinct col1, col2 from table)
select count(*) from temp
;
// 75833 Records Returned
I am not able to figure out why the difference despite the same query.. something elusive hidden somewhere.. requesting all the experts to help me please make me understand.. is this something basic or is this something normal confusion for everyone... Please help me understand
//75048 Records Returned
with temp as (select distinct col1, col2 from table)
select count(*) from temp
;
// 75833 Records Returned
I am not able to figure out why the difference despite the same query.. something elusive hidden somewhere.. requesting all the experts to help me please make me understand.. is this something basic or is this something normal confusion for everyone... Please help me understand
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
Can you try:
Can you show the execution plan with predicates (set autotrace trace explain)
Regards,
Franck.
Can you try:
select count(*) from (select distinct col1 , col2 from table)
in order to see if it comes with a subquery factoring bug ?Can you show the execution plan with predicates (set autotrace trace explain)
Regards,
Franck.
ASKER
Thanks Franck
I am a newbie in the world of programming with database, your statements are way advanced to what I know in sql.
ok now looking at what I would need I would say the need is to pick up just two values from the table as per requirement
select distinct col1, col2 from table1;
col1, col2 both are primary keys. Would the above query ensure that I get only distinct col1 values and col2 values?? If not then what should be done to ensure both the col1 and associate col2 values are distinct ?
I am a newbie in the world of programming with database, your statements are way advanced to what I know in sql.
ok now looking at what I would need I would say the need is to pick up just two values from the table as per requirement
select distinct col1, col2 from table1;
col1, col2 both are primary keys. Would the above query ensure that I get only distinct col1 values and col2 values?? If not then what should be done to ensure both the col1 and associate col2 values are distinct ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks to all
I have seen something like this in 11g with results caching.