[MonetDB-users] Possible wrong results when Querying
Hi There, I have some problem with the row_number() over() function. Consider the following table: create table "table1" ("customer" varchar(40), "product" varchar(40), "price" double) insert into "table1" values ('cust1', 'p1', 100) insert into "table1" values ('cust1', 'p2', 200) insert into "table1" values ('cust1', 'p3', 150) insert into "table1" values ('cust2', 'p1', 300) insert into "table1" values ('cust2', 'p3', 200) The following query over this table: SELECT "customer", "product", "sumprice", (Row_number() OVER(PARTITION BY "customer" ORDER BY "sumprice")) as "rank" FROM ( SELECT "customer", "product", (Sum("price")) AS "sumprice" FROM "table1" GROUP BY "customer", "product") AS "temp" Returns: Customer product sumprice rank Cust1 p1 100 1 Cust1 p2 200 2 Cust1 p3 150 3 Cust2 p1 300 1 Cust2 p3 200 2 But doesn’t it suppose to return the following result set?: Customer product sumprice rank Cust1 p1 100 1 Cust1 p3 150 2 Cust1 p2 200 3 Cust2 p3 200 1 Cust2 p1 200 2 Thanks -- Leonard Forgge -- View this message in context: http://www.nabble.com/Possible-wrong-results-when-Querying-tp22821802p228218... Sent from the monetdb-users mailing list archive at Nabble.com.
Hi, I have experienced this bug too, and am reproducing the example posted here on Aug-SP1 on windows. Is this a known bug? Any prospects of having it fixed? LeonardF wrote:
Hi There,
I have some problem with the row_number() over() function. Consider the following table: create table "table1" ("customer" varchar(40), "product" varchar(40), "price" double) insert into "table1" values ('cust1', 'p1', 100) insert into "table1" values ('cust1', 'p2', 200) insert into "table1" values ('cust1', 'p3', 150) insert into "table1" values ('cust2', 'p1', 300) insert into "table1" values ('cust2', 'p3', 200)
The following query over this table: SELECT "customer", "product", "sumprice", (Row_number() OVER(PARTITION BY "customer" ORDER BY "sumprice")) as "rank" FROM ( SELECT "customer", "product", (Sum("price")) AS "sumprice" FROM "table1" GROUP BY "customer", "product") AS "temp"
Returns: Customer product sumprice rank Cust1 p1 100 1 Cust1 p2 200 2 Cust1 p3 150 3 Cust2 p1 300 1 Cust2 p3 200 2
But doesn’t it suppose to return the following result set?: Customer product sumprice rank Cust1 p1 100 1 Cust1 p3 150 2 Cust1 p2 200 3 Cust2 p3 200 1 Cust2 p1 200 2
Thanks
-- Leonard Forgge
-- View this message in context: http://old.nabble.com/Possible-wrong-results-when-Querying-tp22821802p262812... Sent from the monetdb-users mailing list archive at Nabble.com.
Alex, Leonard, could one of you please report this as bug via https://sourceforge.net/tracker/?atid=482468&group_id=56967&func=browse Please include detailed information to reproduce the problem. Thanks! Stefan On Tue, Nov 10, 2009 at 02:28:05AM -0800, Alex Bo. wrote:
Hi,
I have experienced this bug too, and am reproducing the example posted here on Aug-SP1 on windows.
Is this a known bug? Any prospects of having it fixed?
LeonardF wrote:
Hi There,
I have some problem with the row_number() over() function. Consider the following table: create table "table1" ("customer" varchar(40), "product" varchar(40), "price" double) insert into "table1" values ('cust1', 'p1', 100) insert into "table1" values ('cust1', 'p2', 200) insert into "table1" values ('cust1', 'p3', 150) insert into "table1" values ('cust2', 'p1', 300) insert into "table1" values ('cust2', 'p3', 200)
The following query over this table: SELECT "customer", "product", "sumprice", (Row_number() OVER(PARTITION BY "customer" ORDER BY "sumprice")) as "rank" FROM ( SELECT "customer", "product", (Sum("price")) AS "sumprice" FROM "table1" GROUP BY "customer", "product") AS "temp"
Returns: Customer product sumprice rank Cust1 p1 100 1 Cust1 p2 200 2 Cust1 p3 150 3 Cust2 p1 300 1 Cust2 p3 200 2
But doesn’t it suppose to return the following result set?: Customer product sumprice rank Cust1 p1 100 1 Cust1 p3 150 2 Cust1 p2 200 3 Cust2 p3 200 1 Cust2 p1 200 2
Thanks
-- Leonard Forgge
-- View this message in context: http://old.nabble.com/Possible-wrong-results-when-Querying-tp22821802p262812... Sent from the monetdb-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
-- | Dr. Stefan Manegold | mailto:Stefan.Manegold@cwi.nl | | CWI, P.O.Box 94079 | http://www.cwi.nl/~manegold/ | | 1090 GB Amsterdam | Tel.: +31 (20) 592-4212 | | The Netherlands | Fax : +31 (20) 592-4312 |
participants (3)
-
Alex Bo.
-
LeonardF
-
Stefan Manegold