Re: [SQL] fetch first rows of grouped data

2007-08-27 Thread Joel Richard
That's what I thought at first, but this is not the case. She's looking for the first two dates in -each- city in the table. I initially thought that this could be accomplished with GROUP BY and LIMIT, but GROUP BY can only give you the first date for each city, not the first two dates for

Re: [SQL] Converting from MS Access field aliases

2007-07-12 Thread Joel Richard
On Jul 12, 2007, at 1:23 PM, Tom Lane wrote: chester c young <[EMAIL PROTECTED]> writes: SELECT field1 / 2 AS foo, field2 * 2 AS bar, foo + bar AS total WHERE foo < 12; First, I think it would be great if this worked - like the alias to an update table added in 8.2 - saves a lot of typing

[SQL] Converting from MS Access field aliases

2007-07-12 Thread Joel Richard
Good morning, Oh joyous day! We are upgrading a legacy database system from MS Access to PostgreSQL! Yay! Ok, rejoicing over. Here's our issue and PLEASE point me to the right place if this has been discussed before. In MS Access one can reuse field aliases later in the same query. For