Hi There,

Im trying to figure out a way to order a query by the sum of a colum in 
a MultipleJoin

e.g  (not the original code, its messed up by me trying so many possible 
solutions :)

class Salesman(SQLObject):
   name = StringCol()
   sales = MultipleJoin(Sale)

class Sale(SQLObject):
   salesman = ForeignKey('Salesman')
   amount = IntCol()


Now supposing I want to query a list of all of the Salesmen, ordered by 
the Sum of the amounts of their sales?
Will SQLObject let me do that?

If I was writing plain ole SQL I would do

select salesman.name, sum(sale.amount) from salesman, sale where 
salesman.id = sale.salesman_id group by salesman.id order by sum(sale) 
desc.

I dug through the SQLObject documentation and order by only seems to 
take single column names, I found some references to group by on this 
mailing list, but could not get anything working :(

Thanks for your help

Sean

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to