Why do these two queries return different results? [closed]What is the difference between “INNER JOIN” and “OUTER JOIN”?How do I limit the number of rows returned by an Oracle query after ordering?How can I SELECT rows with MAX(Column value), DISTINCT by another column in SQL?Insert results of a stored procedure into a temporary tableWhen should I use cross apply over inner join?Selecting data from two different servers in SQL ServerHow to 'insert if not exists' in MySQL?SQL Server: How to Join to first rowNested select statement in SQL ServerSQL select only rows with max value on a column

Zhora asks Deckard: "Are you for real?" Was this meant to be significant?

How to remove the first colon ':' from a timestamp?

Why isn't a binary file shown as 0s and 1s?

How slow can a car engine run?

Can firbolgs cast their racial Detect Magic spell as a ritual?

Why aren't there any women super GMs?

Last-minute canceled work-trip mean I'll lose thousands of dollars on planned vacation

I want to identify a part from a photo

Whipping heavy cream with melted chocolate

Why won't some unicode characters print to my terminal?

What details should I consider before agreeing for part of my salary to be 'retained' by employer?

Drawing a circle with nodes shift with Tikz

Everyone but three

How can one convert an expression to a string while keeping the quotation marks of strings that are part of the expression?

Compiler only complains about the ambiguous overloaded functions when the parameter is 0

Did Hitler say this quote about homeschooling?

Time signature inconsistent

What is the period of Langton's ant on a torus?

Why does a tetrahedral molecule like methane have a dipole moment of zero?

What were the problems on the Apollo 11 lunar module?

Is this Android phone Android 9.0 or Android 6.0?

Should I use a resistor between the gate driver and MOSFET (gate pin)?

What happens if a company buys back all of its shares?

What causes a rotating object to rotate forever without external force—inertia, or something else?



Why do these two queries return different results? [closed]


What is the difference between “INNER JOIN” and “OUTER JOIN”?How do I limit the number of rows returned by an Oracle query after ordering?How can I SELECT rows with MAX(Column value), DISTINCT by another column in SQL?Insert results of a stored procedure into a temporary tableWhen should I use cross apply over inner join?Selecting data from two different servers in SQL ServerHow to 'insert if not exists' in MySQL?SQL Server: How to Join to first rowNested select statement in SQL ServerSQL select only rows with max value on a column






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-5















I have these two queries which return different row counts. When we count the rows in the 2nd query, the result would be the same as the 1st query. But it shows a different result. I need to know why.




  1. select count(*) from dual

  2. select * from dual









share|improve this question















closed as unclear what you're asking by Alex Poole, jarlh, Rene, MT0, gnat Mar 26 at 11:44


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.













  • 2





    The solution to what? One is getting actual data, one is counting how many rows there are - why would they get the same results, and why would you want or expect them to?

    – Alex Poole
    Mar 26 at 9:30











  • i know this, but when we ran the query in production, the result row count from the 1st and 2nd query is different

    – paritosh verma
    Mar 26 at 9:52






  • 1





    Query 2 will return all the rows. Query 1 will return 1 row, with the count of rows.

    – jarlh
    Mar 26 at 9:54












  • yes, but the count must be same

    – paritosh verma
    Mar 26 at 9:56











  • Still not sure what you mean. The dual table only has one row (unless your DB is corrupted, of course). The first query will get a single row with the value 1, as that is how many rows there are. The second query will get a single row with value X. If you are somehow seeing something different then include what you actually see in your question.

    – Alex Poole
    Mar 26 at 9:59


















-5















I have these two queries which return different row counts. When we count the rows in the 2nd query, the result would be the same as the 1st query. But it shows a different result. I need to know why.




  1. select count(*) from dual

  2. select * from dual









share|improve this question















closed as unclear what you're asking by Alex Poole, jarlh, Rene, MT0, gnat Mar 26 at 11:44


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.













  • 2





    The solution to what? One is getting actual data, one is counting how many rows there are - why would they get the same results, and why would you want or expect them to?

    – Alex Poole
    Mar 26 at 9:30











  • i know this, but when we ran the query in production, the result row count from the 1st and 2nd query is different

    – paritosh verma
    Mar 26 at 9:52






  • 1





    Query 2 will return all the rows. Query 1 will return 1 row, with the count of rows.

    – jarlh
    Mar 26 at 9:54












  • yes, but the count must be same

    – paritosh verma
    Mar 26 at 9:56











  • Still not sure what you mean. The dual table only has one row (unless your DB is corrupted, of course). The first query will get a single row with the value 1, as that is how many rows there are. The second query will get a single row with value X. If you are somehow seeing something different then include what you actually see in your question.

    – Alex Poole
    Mar 26 at 9:59














-5












-5








-5








I have these two queries which return different row counts. When we count the rows in the 2nd query, the result would be the same as the 1st query. But it shows a different result. I need to know why.




  1. select count(*) from dual

  2. select * from dual









share|improve this question
















I have these two queries which return different row counts. When we count the rows in the 2nd query, the result would be the same as the 1st query. But it shows a different result. I need to know why.




  1. select count(*) from dual

  2. select * from dual






sql oracle oracle10g






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 11:17









marc_s

597k135 gold badges1147 silver badges1284 bronze badges




597k135 gold badges1147 silver badges1284 bronze badges










asked Mar 26 at 9:22









paritosh vermaparitosh verma

12 bronze badges




12 bronze badges




closed as unclear what you're asking by Alex Poole, jarlh, Rene, MT0, gnat Mar 26 at 11:44


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









closed as unclear what you're asking by Alex Poole, jarlh, Rene, MT0, gnat Mar 26 at 11:44


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 2





    The solution to what? One is getting actual data, one is counting how many rows there are - why would they get the same results, and why would you want or expect them to?

    – Alex Poole
    Mar 26 at 9:30











  • i know this, but when we ran the query in production, the result row count from the 1st and 2nd query is different

    – paritosh verma
    Mar 26 at 9:52






  • 1





    Query 2 will return all the rows. Query 1 will return 1 row, with the count of rows.

    – jarlh
    Mar 26 at 9:54












  • yes, but the count must be same

    – paritosh verma
    Mar 26 at 9:56











  • Still not sure what you mean. The dual table only has one row (unless your DB is corrupted, of course). The first query will get a single row with the value 1, as that is how many rows there are. The second query will get a single row with value X. If you are somehow seeing something different then include what you actually see in your question.

    – Alex Poole
    Mar 26 at 9:59













  • 2





    The solution to what? One is getting actual data, one is counting how many rows there are - why would they get the same results, and why would you want or expect them to?

    – Alex Poole
    Mar 26 at 9:30











  • i know this, but when we ran the query in production, the result row count from the 1st and 2nd query is different

    – paritosh verma
    Mar 26 at 9:52






  • 1





    Query 2 will return all the rows. Query 1 will return 1 row, with the count of rows.

    – jarlh
    Mar 26 at 9:54












  • yes, but the count must be same

    – paritosh verma
    Mar 26 at 9:56











  • Still not sure what you mean. The dual table only has one row (unless your DB is corrupted, of course). The first query will get a single row with the value 1, as that is how many rows there are. The second query will get a single row with value X. If you are somehow seeing something different then include what you actually see in your question.

    – Alex Poole
    Mar 26 at 9:59








2




2





The solution to what? One is getting actual data, one is counting how many rows there are - why would they get the same results, and why would you want or expect them to?

– Alex Poole
Mar 26 at 9:30





The solution to what? One is getting actual data, one is counting how many rows there are - why would they get the same results, and why would you want or expect them to?

– Alex Poole
Mar 26 at 9:30













i know this, but when we ran the query in production, the result row count from the 1st and 2nd query is different

– paritosh verma
Mar 26 at 9:52





i know this, but when we ran the query in production, the result row count from the 1st and 2nd query is different

– paritosh verma
Mar 26 at 9:52




1




1





Query 2 will return all the rows. Query 1 will return 1 row, with the count of rows.

– jarlh
Mar 26 at 9:54






Query 2 will return all the rows. Query 1 will return 1 row, with the count of rows.

– jarlh
Mar 26 at 9:54














yes, but the count must be same

– paritosh verma
Mar 26 at 9:56





yes, but the count must be same

– paritosh verma
Mar 26 at 9:56













Still not sure what you mean. The dual table only has one row (unless your DB is corrupted, of course). The first query will get a single row with the value 1, as that is how many rows there are. The second query will get a single row with value X. If you are somehow seeing something different then include what you actually see in your question.

– Alex Poole
Mar 26 at 9:59






Still not sure what you mean. The dual table only has one row (unless your DB is corrupted, of course). The first query will get a single row with the value 1, as that is how many rows there are. The second query will get a single row with value X. If you are somehow seeing something different then include what you actually see in your question.

– Alex Poole
Mar 26 at 9:59













1 Answer
1






active

oldest

votes


















1














An * means "everything and anything". So basically this query:



select * from dual


Means "show me everything from dual".
Count literally means "count me the number of something"



count(*)


Is to count everything!



Take this as an example:



create table example (id int(1), ex1 varchar(15), ex2 varchar(15), ex3 varchar(15));
insert into example values(1, 'whatever11', 'whatever12', 'whatever13');
insert into example values(2, 'whatever21', 'whatever22', 'whatever23');
insert into example values(3, 'whatever31', 'whatever32', 'whatever33');


So a select * would mean to show me all the 3 rows that are inserted, with all the values:



enter image description here



But a select count(*) would mean to show me the number of rows there are. In this case, with id 1, id 2, and id 3 , there are 3 rows, so the result would be 3!



enter image description here






share|improve this answer























  • yes, but when we ran the query in production, the result count from the 1st and 2nd query is different.

    – paritosh verma
    Mar 26 at 9:46












  • it should not be same according to oracle because the execution plan is different for the above 2 query, i need to know how can i make the result same to avoid data gaps.

    – paritosh verma
    Mar 26 at 9:47











  • Read my answer in detail please! Of course it is different the result of the first and the second! They do different things! They can never show the same output. One counts the result of everything. The number of times it appears. The other (1st) shows all the data... It can never be the same @paritoshverma If the answer was useful or nice anyways, remember to upvote it

    – M.K
    Mar 26 at 9:48











  • of course, you said it! It should not be the same! That is why! @paritoshverma

    – M.K
    Mar 26 at 9:48











  • i know this, but when we ran the query in production, the result row count from the 1st and 2nd query is different

    – paritosh verma
    Mar 26 at 9:53














1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














An * means "everything and anything". So basically this query:



select * from dual


Means "show me everything from dual".
Count literally means "count me the number of something"



count(*)


Is to count everything!



Take this as an example:



create table example (id int(1), ex1 varchar(15), ex2 varchar(15), ex3 varchar(15));
insert into example values(1, 'whatever11', 'whatever12', 'whatever13');
insert into example values(2, 'whatever21', 'whatever22', 'whatever23');
insert into example values(3, 'whatever31', 'whatever32', 'whatever33');


So a select * would mean to show me all the 3 rows that are inserted, with all the values:



enter image description here



But a select count(*) would mean to show me the number of rows there are. In this case, with id 1, id 2, and id 3 , there are 3 rows, so the result would be 3!



enter image description here






share|improve this answer























  • yes, but when we ran the query in production, the result count from the 1st and 2nd query is different.

    – paritosh verma
    Mar 26 at 9:46












  • it should not be same according to oracle because the execution plan is different for the above 2 query, i need to know how can i make the result same to avoid data gaps.

    – paritosh verma
    Mar 26 at 9:47











  • Read my answer in detail please! Of course it is different the result of the first and the second! They do different things! They can never show the same output. One counts the result of everything. The number of times it appears. The other (1st) shows all the data... It can never be the same @paritoshverma If the answer was useful or nice anyways, remember to upvote it

    – M.K
    Mar 26 at 9:48











  • of course, you said it! It should not be the same! That is why! @paritoshverma

    – M.K
    Mar 26 at 9:48











  • i know this, but when we ran the query in production, the result row count from the 1st and 2nd query is different

    – paritosh verma
    Mar 26 at 9:53















1














An * means "everything and anything". So basically this query:



select * from dual


Means "show me everything from dual".
Count literally means "count me the number of something"



count(*)


Is to count everything!



Take this as an example:



create table example (id int(1), ex1 varchar(15), ex2 varchar(15), ex3 varchar(15));
insert into example values(1, 'whatever11', 'whatever12', 'whatever13');
insert into example values(2, 'whatever21', 'whatever22', 'whatever23');
insert into example values(3, 'whatever31', 'whatever32', 'whatever33');


So a select * would mean to show me all the 3 rows that are inserted, with all the values:



enter image description here



But a select count(*) would mean to show me the number of rows there are. In this case, with id 1, id 2, and id 3 , there are 3 rows, so the result would be 3!



enter image description here






share|improve this answer























  • yes, but when we ran the query in production, the result count from the 1st and 2nd query is different.

    – paritosh verma
    Mar 26 at 9:46












  • it should not be same according to oracle because the execution plan is different for the above 2 query, i need to know how can i make the result same to avoid data gaps.

    – paritosh verma
    Mar 26 at 9:47











  • Read my answer in detail please! Of course it is different the result of the first and the second! They do different things! They can never show the same output. One counts the result of everything. The number of times it appears. The other (1st) shows all the data... It can never be the same @paritoshverma If the answer was useful or nice anyways, remember to upvote it

    – M.K
    Mar 26 at 9:48











  • of course, you said it! It should not be the same! That is why! @paritoshverma

    – M.K
    Mar 26 at 9:48











  • i know this, but when we ran the query in production, the result row count from the 1st and 2nd query is different

    – paritosh verma
    Mar 26 at 9:53













1












1








1







An * means "everything and anything". So basically this query:



select * from dual


Means "show me everything from dual".
Count literally means "count me the number of something"



count(*)


Is to count everything!



Take this as an example:



create table example (id int(1), ex1 varchar(15), ex2 varchar(15), ex3 varchar(15));
insert into example values(1, 'whatever11', 'whatever12', 'whatever13');
insert into example values(2, 'whatever21', 'whatever22', 'whatever23');
insert into example values(3, 'whatever31', 'whatever32', 'whatever33');


So a select * would mean to show me all the 3 rows that are inserted, with all the values:



enter image description here



But a select count(*) would mean to show me the number of rows there are. In this case, with id 1, id 2, and id 3 , there are 3 rows, so the result would be 3!



enter image description here






share|improve this answer













An * means "everything and anything". So basically this query:



select * from dual


Means "show me everything from dual".
Count literally means "count me the number of something"



count(*)


Is to count everything!



Take this as an example:



create table example (id int(1), ex1 varchar(15), ex2 varchar(15), ex3 varchar(15));
insert into example values(1, 'whatever11', 'whatever12', 'whatever13');
insert into example values(2, 'whatever21', 'whatever22', 'whatever23');
insert into example values(3, 'whatever31', 'whatever32', 'whatever33');


So a select * would mean to show me all the 3 rows that are inserted, with all the values:



enter image description here



But a select count(*) would mean to show me the number of rows there are. In this case, with id 1, id 2, and id 3 , there are 3 rows, so the result would be 3!



enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 26 at 9:33









M.KM.K

1,1651 gold badge10 silver badges26 bronze badges




1,1651 gold badge10 silver badges26 bronze badges












  • yes, but when we ran the query in production, the result count from the 1st and 2nd query is different.

    – paritosh verma
    Mar 26 at 9:46












  • it should not be same according to oracle because the execution plan is different for the above 2 query, i need to know how can i make the result same to avoid data gaps.

    – paritosh verma
    Mar 26 at 9:47











  • Read my answer in detail please! Of course it is different the result of the first and the second! They do different things! They can never show the same output. One counts the result of everything. The number of times it appears. The other (1st) shows all the data... It can never be the same @paritoshverma If the answer was useful or nice anyways, remember to upvote it

    – M.K
    Mar 26 at 9:48











  • of course, you said it! It should not be the same! That is why! @paritoshverma

    – M.K
    Mar 26 at 9:48











  • i know this, but when we ran the query in production, the result row count from the 1st and 2nd query is different

    – paritosh verma
    Mar 26 at 9:53

















  • yes, but when we ran the query in production, the result count from the 1st and 2nd query is different.

    – paritosh verma
    Mar 26 at 9:46












  • it should not be same according to oracle because the execution plan is different for the above 2 query, i need to know how can i make the result same to avoid data gaps.

    – paritosh verma
    Mar 26 at 9:47











  • Read my answer in detail please! Of course it is different the result of the first and the second! They do different things! They can never show the same output. One counts the result of everything. The number of times it appears. The other (1st) shows all the data... It can never be the same @paritoshverma If the answer was useful or nice anyways, remember to upvote it

    – M.K
    Mar 26 at 9:48











  • of course, you said it! It should not be the same! That is why! @paritoshverma

    – M.K
    Mar 26 at 9:48











  • i know this, but when we ran the query in production, the result row count from the 1st and 2nd query is different

    – paritosh verma
    Mar 26 at 9:53
















yes, but when we ran the query in production, the result count from the 1st and 2nd query is different.

– paritosh verma
Mar 26 at 9:46






yes, but when we ran the query in production, the result count from the 1st and 2nd query is different.

– paritosh verma
Mar 26 at 9:46














it should not be same according to oracle because the execution plan is different for the above 2 query, i need to know how can i make the result same to avoid data gaps.

– paritosh verma
Mar 26 at 9:47





it should not be same according to oracle because the execution plan is different for the above 2 query, i need to know how can i make the result same to avoid data gaps.

– paritosh verma
Mar 26 at 9:47













Read my answer in detail please! Of course it is different the result of the first and the second! They do different things! They can never show the same output. One counts the result of everything. The number of times it appears. The other (1st) shows all the data... It can never be the same @paritoshverma If the answer was useful or nice anyways, remember to upvote it

– M.K
Mar 26 at 9:48





Read my answer in detail please! Of course it is different the result of the first and the second! They do different things! They can never show the same output. One counts the result of everything. The number of times it appears. The other (1st) shows all the data... It can never be the same @paritoshverma If the answer was useful or nice anyways, remember to upvote it

– M.K
Mar 26 at 9:48













of course, you said it! It should not be the same! That is why! @paritoshverma

– M.K
Mar 26 at 9:48





of course, you said it! It should not be the same! That is why! @paritoshverma

– M.K
Mar 26 at 9:48













i know this, but when we ran the query in production, the result row count from the 1st and 2nd query is different

– paritosh verma
Mar 26 at 9:53





i know this, but when we ran the query in production, the result row count from the 1st and 2nd query is different

– paritosh verma
Mar 26 at 9:53








Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.





Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현