× Heads up!

Aqua Data Studio / nhilam

Follow
IDE for Relational Databases
×
slavakiev reported 2013-07-23T20:27:04Z  · last modified 2013-08-02T19:42:24Z

Wrong realization of COUNT() in case when aggregation framework involved when GROUP BY is absent


Priority Major
Complexity Unknown
Component MongoSQL
Version 14.0

Tested Aqua Data Studio Aqua Data Studio 14.0.0-beta-68 Build #: 33238 on Ubuntu 12.04( Mongo DB 2.4.3)  and Windows XP ( Mongo DB 2.0.9).

In case when SQL statement has no GROUP BY but elements of WHAT clause causes to use aggregate framework realization of COUNT( ) done in the program by using $cond statement in $group  and this returns 0. See result of next statement:     
 
select count(valuation),sum(valuation/valuation) from baseball
go
 
--count(valuation)    sum(valuation/valuation)
---------                    ----------------
--0                          1
 
Correct result can be obtained If $cond statement use in the project instead  $group:
 
db.baseball.aggregate( { "$project" :{ "valuation / valuation" : { "$divide" : [ "$valuation", "$valuation" ]} , "valcond":{"$cond" : [ { "$or" : [ "$valuation", { "$eq" : [ "$valuation", null ] } ] }, 1, 0 ] } }},{ "$group" : { "_id" : null , "count(valuation)" : { "$sum" : "$valcond" }, "sum(valuation / valuation)" : { "$sum" : "$valuation / valuation" } } } )     
 
 
 
 

Issue #9644

Closed
Fixed
Resolved 2013-07-31T21:08:39Z
 
 
Completion
No due date
Fixed Build ADS 14.0.0-beta-76 (mongo-jdbc 1.2.6)
No time estimate

About AquaClusters Privacy Policy Support Version - 19.0.2-4 AquaFold, Inc Copyright © 2007-2017