[web2py] Re: Problem with difficult query

2013-02-07 Thread Jake Lowen
Solved: It was a dumb mistake.. I was trying to group by a field in the left join table.. so of course it was eliminating all records not found in the second table. I switched the group by to a first table field and all is well. Final working query was: foo = db(db.benchmark_targets.benchmar

[web2py] Re: Problem with difficult query

2013-02-07 Thread Jake Lowen
I'm only talking to myself here, but the notes are helpful... This is how I get the desired result in web2py using the executesql command: foo = db.executesql('SELECT * FROM benchmark_targets AS t2 LEFT JOIN (SELECT * from lobby_report GROUP BY KPID ORDER BY datetime DESC) AS t1 ON t2.KPID = t1

[web2py] Re: Problem with difficult query

2013-02-07 Thread Jake Lowen
Forgot the WHERE in my SQL statement. Should be: SELECT * FROM benchmark_targets t2 LEFT JOIN (SELECT * from lobby_report GROUP BY KPID ORDER BY datetime DESC)t1 ON t2.KPID = t1.KPID WHERE t2.benchmark = 10; -- --- You received this message because you are subscribed to the Google Groups

[web2py] Re: Problem with difficult query

2013-02-07 Thread Jake Lowen
If it helps, here is how I can get the desired result in raw SQL: SELECT * FROM benchmark_targets t2 LEFT JOIN (SELECT * from lobby_report GROUP BY KPID ORDER BY datetime DESC)t1 ON t2.KPID = t1.KPID; Now how to do it in DAL? -- --- You received this message because you are subscribed to th