Solved it by using 2 seperate queries:
rij = db().select(
db.track_trace.id_reparaties, db.track_trace.id_status,
db.track_trace.created_by, max,
groupby=~db.track_trace.id_reparaties,
having=(db.track_trace.id_status == 4))
ids = []
for item in rij:
Thanks you almost had it,
max = db.track_trace.created_on.max()
having = (db.track_trace.id_status == 11)
rij = db().select(db.track_trace.id_reparaties, db.track_trace.id_status, max,
groupby=~db.track_trace.id_reparaties,having=(db.track_trace.id_status == 11))
The above code is working and
And again everything gets deleted.. I don't understand
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are
hmm another reply just gets deleted, immediately after posting(something
wrong with my other account I think)
I tried somethings now and I am a step closer:
max = db.track_trace.created_on.max()
recs = db().select(db.track_trace.id_status, max, groupby=db.track_trace.
id_reparaties)
Now I get
I tried some variations but no correct output so far
max = db.track_trace.created_on.max()
recs = db().select(max,db.track_trace.id_status, groupby=db.track_trace.
id_reparaties)
With this I get the max date, but not the id_status that belongs to that
date
--
Resources:
-
Hi,
I made the query with SQL:
select id_reparaties, id_status, max(created_on)
from track_trace
group by id_reparaties desc
having id_status=11
this gives me the correct results as far as I can see. How do I translate
this into a web2py dal query?
Op donderdag 27 februari 2014 13:47:46
perhaps something like :
*not tested*
max = db.track_trace.created_on.max()
max_result = db().select(max).first()[max]
query_having = (db.track_trace.id_status == 11)
db().select(db.track_trace.id_reparaties, db.track_trace.id_reparaties,
max_result,
groupby = db.track_trace.id_reparaties,
I'll try to make it better ;).
For example I have the following list:
id | id_reparaties | id_status | created_on
1 | 1 | 1 | 01-01-14
2 | 1 | 3 | 15-01-14
3 | 2 | 1 | 02-01-14
4 | 3 | 1 | 16-01-14
5 | 1
hmm somehow my reply got deleted.. I want to count the groups that have a
certain id_status as their newest item. The group will indeed give 1 item,
but I want to know how many groups.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
-
This must be a googlegroup bug. We did not delete them.
On Tuesday, 4 March 2014 14:30:54 UTC-6, Bastiaan van der Veen wrote:
Somehow my replies all got deleted.
I want one item per group(the newest) and then filter by id_status and
count how many groups have that certain id_status. This
your request kinda sound bad.
if you want to:
- filter by id_status
- group by id_reperaties
- count lines
then it's fine.
That have the newest item is the part that doesn't sound right. The
newest item is always going to be one and only one, so counting would just
return 1 for every group
On 24 jul, 19:01, weheh richard_gor...@verizon.net wrote:
I have a list, x, with allowed values for field table.x. Is there a
succinct way to do something like this?
db(db.table.x in x).select()
Hi,
You must use the operator Belongs. Please see here [1]
Regards
Jose
[1]
Thanks Jose, I just figured it out.
13 matches
Mail list logo