mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-12 23:22:53 +03:00
Allow a HAVING clause on any aggregate query, even if there is no GROUP BY
clause. This brings SQLite into closer agreement with PostgreSQL and fixes the concern raised by [forum:/forumpost/1a7fea4651|forum post 1a7fea4651]. FossilOrigin-Name: 9322a7c21f1c22ba00e9b889223e89bc1591db6e561ce05091e905e98c1bf2b3
This commit is contained in:
@@ -1824,8 +1824,8 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
|
||||
sNC.uNC.pEList = p->pEList;
|
||||
sNC.ncFlags |= NC_UEList;
|
||||
if( p->pHaving ){
|
||||
if( !pGroupBy ){
|
||||
sqlite3ErrorMsg(pParse, "a GROUP BY clause is required before HAVING");
|
||||
if( (p->selFlags & SF_Aggregate)==0 ){
|
||||
sqlite3ErrorMsg(pParse, "HAVING clause on a non-aggregate query");
|
||||
return WRC_Abort;
|
||||
}
|
||||
if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort;
|
||||
|
Reference in New Issue
Block a user