Re: [SQL] WHERE on an alias

2001-08-28 Thread Andre Schnabel
- Original Message - From: "Joseph Shraibman" <[EMAIL PROTECTED]> Subject: Re: [SQL] WHERE on an alias > If I try to put a distinct on in my subselect int the from I get: > > ERROR: SELECT DISTINCT ON expressions must match initial ORDER BY expressions > > what does that mean? You need

[SQL] List archives moved and cleaned up ...

2001-08-28 Thread Marc G. Fournier
Finally figuring that enough is enough, I've been spending the past few days working on the list archives ... I've reformatted, so far, the following lists into a cleaner format: pgsql-hackers pgsql-sql pgsql-bugs pgsql-general pgadmin-hackers pga

Re: [SQL] WHERE on an alias

2001-08-28 Thread Joseph Shraibman
If I try to put a distinct on in my subselect int the from I get: ERROR: SELECT DISTINCT ON expressions must match initial ORDER BY expressions what does that mean? Tom Lane wrote: > Joseph Shraibman <[EMAIL PROTECTED]> writes: > >>Basically there is the utable, which has two keys in it. I w

[SQL] On Differing Optimizer Choices ( Again)

2001-08-28 Thread Mark kirkwood
Dear all, Tom's comments on my previous posting encouraged me think some more about this... and now I believe got to the heart of what I was attempting to get accross before. I have a fresh and hopefully clear example. Ok lets start with a small table called 'dim0' that has a unique key call

Re: [SQL] Why is GROUP BY required when aggregate function used?

2001-08-28 Thread Peter Eisentraut
jkinsley writes: > When I add append GROUP BY p2.emp to the query, I no longer get the > error and the results are returned. Why must I explicitly declare a > GROUP BY on the query? Because otherwise it's undefined which p2.emp to return. Consider this table t1: a | b ---+--- 1 | 5 6 | 2

[SQL] Why is GROUP BY required when aggregate function used?

2001-08-28 Thread jkinsley
I am using PostgreSQL to cook the "Nested Set Model of Trees in SQL' examples from Chapter 29 of Joe Celko's book "SQL For Smarties". In Section 29.3 ("Finding Levels and Paths in a Tree"), the following query is used: SELECT P2.emp FROM (COUNT(p1.emp) - 1) AS level FROM Person