Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > DISTINCT ON (fi...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 3520 of 3799
Post > Topic >>

DISTINCT ON (field) behaves different inside view definition, appears

by =?ISO-8859-1?Q?Frank_J=F6rdens?= <frank@[EMAIL PROTECTED] > Jun 11, 2008 at 02:21 PM

Filtering duplicates in this way here works as expected:

woome_app=# select distinct on (ws.id) ws.id, sm.person_id from 
webapp_session ws join sessionmeeting_meeting sm on ws.id = 
sm.session_id where sm.person_id = 45;
   id   | person_id
-------+-----------
  62577 |        45
  62588 |        45
  66598 |        45
  74521 |        45
(4 rows)

Wrapping this query into a view like so:

create view fubar as select distinct on (ws.id) ws.id, sm.person_id from 
webapp_session ws join sessionmeeting_meeting sm on ws.id = sm.session_id;

And applying the same filter to it as above, I get:

woome_app=# select id, person_id from fubar where person_id = 45;
   id   | person_id
-------+-----------
  62577 |        45
  62588 |        45
(2 rows)

i.e. it appears to drop 2 rows it shouldn't. Did I find a bug or can 
anyone explain why this behaviour might be expected?

Frank
 




 2 Posts in Topic:
DISTINCT ON (field) behaves different inside view definition, ap
=?ISO-8859-1?Q?Frank_J=F6  2008-06-11 14:21:33 
Re: DISTINCT ON (field) behaves different inside view definition
=?ISO-8859-1?Q?Frank_J=F6  2008-06-11 14:22:35 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Dec 2 21:33:59 CST 2008.