[web2py] Re: Query results from 2 children tables from same parent ordered by date

2012-12-22 Thread Mamisoa Andriantafika
ok find it too using this code in view: {{for e in exams_mutex:}} divh1Examen du {{=e['COALESCE(dataset1.date,dataset2.date)']}}/h1/div {{pass}} Le samedi 22 décembre 2012 08:27:03 UTC+1, Mamisoa Andriantafika a écrit : I actually need to display those coalesce dates out of SQLTABLE that I

[web2py] Re: Query results from 2 children tables from same parent ordered by date

2012-12-21 Thread Mamisoa Andriantafika
I have pb to show the coalesce date in view. I tried; exams_mutex['COALESCE(dataset1.date,dataset1.date)'] but it is not working? Le jeudi 20 décembre 2012 23:40:15 UTC+1, Mamisoa Andriantafika a écrit : I finally found the solution using COALESCE to merge and order date columns:

[web2py] Re: Query results from 2 children tables from same parent ordered by date

2012-12-21 Thread Derek
If you only need one date, why not display just one date? On Friday, December 21, 2012 2:01:59 PM UTC-7, Mamisoa Andriantafika wrote: I have pb to show the coalesce date in view. I tried; exams_mutex['COALESCE(dataset1.date,dataset1.date)'] but it is not working? Le jeudi 20 décembre

[web2py] Re: Query results from 2 children tables from same parent ordered by date

2012-12-21 Thread Mamisoa Andriantafika
I actually need to display those coalesce dates out of SQLTABLE that I use in view. To be precise, I need to show in LI(date, LI(all parameters)). --

[web2py] Re: Query results from 2 children tables from same parent ordered by date

2012-12-20 Thread Massimo Di Pierro
Sorry I do not have a good solution at the moment. Can you open a ticket about this so we'll will not forget. For now you may want to consider creating a database view and selecting from the view. You would need to create a model (readonly) to access the view. On Wednesday, 19 December 2012

[web2py] Re: Query results from 2 children tables from same parent ordered by date

2012-12-20 Thread Mamisoa Andriantafika
I finally found the solution using COALESCE to merge and order date columns: exams_mutex = db().select(db.dataset1.date.coalesce(db.dataset2.date), db. dataset1.ALL, db.dataset2.ALL, left=[db.dataset1.on(db.mutex.i==0),db. dataset2.on(db.mutex.i==1)],

[web2py] Re: Query results from 2 children tables from same parent ordered by date

2012-12-20 Thread Massimo Di Pierro
Nice! You should sign up on experts4solutions.com. You'd approve you immediately. Massimo On Thursday, December 20, 2012 4:40:15 PM UTC-6, Mamisoa Andriantafika wrote: I finally found the solution using COALESCE to merge and order date columns: exams_mutex =

[web2py] Re: Query results from 2 children tables from same parent ordered by date

2012-12-19 Thread Mamisoa Andriantafika
Best results to UNION I could have was using the mutex table trick: http://www.xaprb.com/blog/2006/05/26/how-to-write-full-outer-join-in-mysql/ with this syntax: exams_mutex = db().select(db.dataset1.ALL, db.dataset2.ALL, left=[db.dataset1.on(db.mutex.i==0),db.dataset2.on(db.mutex.i==1)]) Two

[web2py] Re: Query results from 2 children tables from same parent ordered by date

2012-12-16 Thread Mamisoa Andriantafika
Hi again, | seems not to work because the column numbers is different between the 2 tables? Le samedi 15 décembre 2012 20:23:44 UTC+1, Massimo Di Pierro a écrit : If you have lots of records you may be able to do it with a database view but that may be db specific. If you don't have too

[web2py] Re: Query results from 2 children tables from same parent ordered by date

2012-12-16 Thread Massimo Di Pierro
My bad. Thry this: fields1 = [db.dataset1.date, db.dataset1.param1, db.dateset1.patient_id] fields2 = [db.dataset2.date, db.dataset2.test1, db.dateset2.patient_id] rows = ( db(db.dataset1).select(*fields1) | db(db.dataset2).select(*fields2) ).sort(lambda row: row.date) Mind that having a column

[web2py] Re: Query results from 2 children tables from same parent ordered by date

2012-12-16 Thread Mamisoa Andriantafika
Sorry I still get: Cannot | incompatible Rows objects. I'll change the field name date you are very right. Le dimanche 16 décembre 2012 15:49:57 UTC+1, Massimo Di Pierro a écrit : My bad. Thry this: fields1 = [db.dataset1.date, db.dataset1.param1, db.dateset1.patient_id] fields2 =

[web2py] Re: Query results from 2 children tables from same parent ordered by date

2012-12-15 Thread Massimo Di Pierro
If you have lots of records you may be able to do it with a database view but that may be db specific. If you don't have too many records you can do: rows = ( db(db.dataset1).select() | db(db.dataset2).select() ).sort(lambda row: row.date) On Saturday, 15 December 2012 08:43:35 UTC-6,

[web2py] Re: Query results from 2 children tables from same parent ordered by date

2012-12-15 Thread Mamisoa Andriantafika
Thank you for your answer. What do you mean by: 1) too many records: I have about 1k per dataset 2) database view? Le samedi 15 décembre 2012 20:23:44 UTC+1, Massimo Di Pierro a écrit : If you have lots of records you may be able to do it with a database view but that may be db specific.

[web2py] Re: Query results from 2 children tables from same parent ordered by date

2012-12-15 Thread Massimo Di Pierro
On Saturday, December 15, 2012 2:04:28 PM UTC-6, Mamisoa Andriantafika wrote: Thank you for your answer. What do you mean by: 1) too many records: I have about 1k per dataset I mean the sorting I suggested is performed in ram, in Python. If that is not slow than ok. 2) database