why there are two TargetEntrys in Query when i use "select count(catcode) from pois group by catcode"?

Started by sunpengalmost 16 years ago2 messagesgeneral
Jump to latest
#1sunpeng
bluevaley@gmail.com

I've the table
CREATE TABLE pois
(
uid integer not null,
name VARCHAR(128),
catcode VARCHAR(32) not null,
catname VARCHAR(32),
others VARCHAR(32)
);
after i execute "select count(*) from pois group by catcode";
the log of query.targetList is :
:targetList (
{TARGETENTRY
:expr
{AGGREF
:aggfnoid 2803
:aggtype 20
:args <>
:agglevelsup 0
:aggstar true
:aggdistinct false
:location 7
}
:resno 1
:resname count
:ressortgroupref 0
:resorigtbl 0
:resorigcol 0
:resjunk false
}
{TARGETENTRY
:expr
{VAR
:varno 1
:varattno 3
:vartype 1043
:vartypmod 36
:varlevelsup 0
:varnoold 1
:varoattno 3
:location 35
}
:resno 2
:resname <>
:ressortgroupref 1
:resorigtbl 0
:resorigcol 0
:resjunk true
}
)
why there is the second TARGETENTRY? what's the purpose of the second
TARGETENTRY?

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: sunpeng (#1)
Re: why there are two TargetEntrys in Query when i use "select count(catcode) from pois group by catcode"?

sunpeng <bluevaley@gmail.com> writes:

after i execute "select count(*) from pois group by catcode";
the log of query.targetList is :
why there is the second TARGETENTRY? what's the purpose of the second
TARGETENTRY?

It's the GROUP BY expression. Note the ressortgroupref and resjunk
settings.

regards, tom lane