I'm trying to get a row count on a query that joins together every instance 
of a coalesce set of fields and coming unstuck.

The query in sql looks like:

select sum(1) from (select count(direction) from tracking
where
direction = 1
AND
left(created,10) = '2014-06-13'
group by COALESCE(ticketnumber,memid)
order by COALESCE(ticketnumber,memid)) as test

is there a more efficient way to do this or a would i need to use web2py 
python code to loop and count the below?

I've started without the coalesce and can return the query, but can't get 
my head around the most efficient way to get the row count, so far have:
peakattq = db((db.tracking.created[:10]==reportdate)&(db.tracking.direction
==1)).select(db.tracking.direction.count(), groupby=db.tracking.ticketnumber
, orderby=db.tracking.ticketnumber)
return peakattq['COUNT(tracking.direction)']

would really appreciate any help, as i've not done web2py for a while now 
and my brain is hurting.

-- 
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 subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to