[BangPypers] getpython.net Sprint (was Re: User group meeting)

Baiju M baiju.m.mail at gmail.com
Mon Jan 31 07:35:30 CET 2011

On Mon, Jan 31, 2011 at 11:36 AM, Anand Balachandran Pillai
<abpillai at gmail.com> wrote:
> Very useful project! I was looking for something like this the other day.
> Didn't know this was getting made right here :)
> Congrats to everyone who contributed to this! I guess this is the
> first project closer to a "community" project being executed by people
> in this group.

This was a new experience for all of us.  I hope we can do
much bigger sprints in future.

I need two more SQL queries :)


One query is ready but need to convert it into SQLAlchmey.
Here is the query (it's working fine):

    # select * from distributions inner join (select * from comments where
    # comments.id in (select max(comments.id) as id from comments group by
    # comments.distribution_id)) a on distributions.id = a.distribution_id
    # order by a.datetime desc

(The above logic is to find the latest feedback without duplicate distribution
  names.  For example if a distribution has two recent feedback, I just
  need latest among those. And I need to get total 5 latest feedbacks)


For the second one, I have a rough query which is not working:

     select name,successcnt,failcnt from distributions d
     inner join
         select  distribution_id,
         sum(case when check=true then 1 else 0 end) as successcnt,
         sum(case when chec=false then 1 else end ) as failcnt
         comments where datetime between(currendate,currentdate-60)
         group by distribution_id) a on a.distribution_id =d.distribution_idn

The idea is to list the popular distributions.  The logic I required is
distributions with minimum 5 feedback and there should be atleast
two feedback recently (within 1 or 2 months).  The output should
give distro name, success count, failure count.

Again I need this in SQLAlchemy syntax.

Baiju M

More information about the BangPypers mailing list