sql - Multiple count() invocations with the same argument in one query -


suppose have table persons:

create table persons (      id integer,      age integer,      primary key (id) ); 

is there difference between following 2 queries?

query #1:

select age, count(*)  persons  group age  order count(*); 

query #2:

select age, count(*) cnt  persons  group age  order cnt; 

will first query count() twice, or optimized away query planner? depend on vendor or defined standard?

both query have same effect.

if run both these query parallel ,query cost showing same.

enter image description here


Comments

Popular posts from this blog

many to many - Django Rest Framework ManyToMany filter multiple values -

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

Java Entity Manager - JSON reader was expecting a value but found 'db' -