Sqlalchemy Querying and filtering -


Then you can say that I have some simple classes like

  class person's birthday   

And I want the oldest person from every state, I think I should do it

  db.session.query (address)    
  class pet species     / former> 

And I Find out the oldest person as follows I am ...

  John - MI - dog - 50 Alex - MI - dog - 51 jo - MI - cat - 10 Tina - Florida - cat - 20   

I just want

  Alex, Joe, Tina   

But not John, because he was not the oldest.

How do I create a query to go about doing this? Which topic should I learn?

This is by far my best effort. This code is specific to my database:

  def most_recent_completed_uss (user): lids = [] in user.organizations: for o.survey_headers for sh: sh.survey_sections in ss : L = Datetime.datetime (1,1,1) lid = none for uss in ss.user_survey_sections: if o.id == uss.organization.id: if l == datetime.datetime (1,1,1 ): Lid = Uss.id if (uss.completed_date and uss.completed_date & gt; = l): l = uss.completed_date lid = uss.id lids.append Return Lids   < P> Absolutely nested for 4 loops and lack of inquiry I think this is a lesser ideal solution.   

If you can use different (...) by using PostgreSQL, Which takes the first line in each group. In Python:

  session.kudi (person) .join (address, stomach). Distinction (address.state, pettipesis) .order_by (  

which will produce something similar:

 Select  on difference (address.state, pet Animal species) person * person involved in contact with person.addi_id = address.add pet on pet pet.People = id addressed by person. State, pet species, person birthdate    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -