e rows it finds on the way back.
>
>
> On Oct 3, 2013, at 2:35 PM, Nathan Mailg wrote:
>
>> Sorry for this follow-up, but I'm really at a loss as to what to check next…
>>
>> What should I do if after I insert a new "Appl" row, the query we've
me, firstname;
Another odd thing is in my application, I have another search feature, and it's
using an SA query that's not using the cte/distinct query below, and it works!
Sorry to have to ask this, but I'm stuck and need to get this working.
Thanks again for all the help!
On Oct
Thanks Mike, that works!
I really appreciate you taking the time to show me how to get this working.
Do you have an amazon wish list or something like that somewhere?
On Sep 30, 2013, at 2:09 PM, Michael Bayer wrote:
> qlast, qfirst = 'a', 'b'
> d = DBSession.query(Appl).\
> distinct(Appl.r
On Sep 20, 2013, at 11:59 AM, Michael Bayer wrote:
>
> Ok now I'm still not following - in this case, "row" is a NamedTuple, or a
> mapped instance? if its a NamedTuple then you don't have the service of
> traversing along object relationships available since the NamedTuple isn't a
> mapped
On Sep 19, 2013, at 3:07 PM, Michael Bayer wrote:
>
> On Sep 19, 2013, at 2:46 PM, Nathan Mailg wrote:
>
>> c = aliased(City)
>> q2 = s.query(q1).\
>> join(Appl.city).\
>> join(c, Appl.city).\
>> order_by(q1.c.lastname, q1.c.firstname
refid, distinct_query.appldate AS
> distinct_query_appldate
> FROM distinct_query ORDER BY distinct_query.lastname, distinct_query.firstname
>
>
> I know this is not exactly the same, but the query itself is a SELECT
> DISTINCT ON(x), which seems to be what they're
Using q1:
q1 = s.query(Appl).\
distinct(Appl.refid).\
filter(Appl.lastname.ilike('Williamson%')).\
filter(Appl.firstname.ilike('d%')).\
group_by(Appl).\
order_by(Appl.refid, Appl.appldate.desc())
this q2 works as a simple join:
q2 = s.query(q1).\
j
_query_firstname,
> distinct_query.lastname AS distinct_query_lastname, distinct_query.refid AS
> distinct_query_refid, distinct_query.appldate AS distinct_query_appldate
> FROM distinct_query ORDER BY distinct_query.lastname, distinct_query.firstname
>
> turning it into aliase
I'm using SA 0.8.2 and trying to port this query that works with PostgreSQL
9.2.4:
WITH distinct_query AS (
SELECT DISTINCT ON (refid) *
FROM appl
WHERE lastname ILIKE 'Williamson%' AND firstname ILIKE 'd%'
GROUP BY refid, id, lastname, firstname, appldate
ORDE