Thanks Niphlod.

I worked for me.

Here is the complete code.

In my controller:


sum_of_entries = db.mydiary.id.count()
year_part = db.mydiary.Entry_Date.year()
distinct_years = db(db.mydiary.id > 0).select(sum_of_entries, year_part, 
groupby=db.mydiary.Entry_Date.year(), orderby=~sum_of_entries)

In my view:
<ul class="list-group">
{{for y in distinct_years:}}
{{yr=y[year_part]}}
{{count=y[sum_of_entries]}}
<li class="list-group-item">{{=A(yr, _href=URL("year",args=yr))}}<span class
="badge pull-right">{{=count}}</span></li>
{{pass}}
</ul>

-- 
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