Giter Site home page Giter Site logo

Muliples With joins about django-cte HOT 3 CLOSED

dimagi avatar dimagi commented on July 22, 2024
Muliples With joins

from django-cte.

Comments (3)

millerdev avatar millerdev commented on July 22, 2024

Hi @cchavez, you have not specified how first_with is related to second_with, so I cannot construct an example. They need to be joined somehow. test_named_ctes has examples of how to do this, but that test seems a bit more complicated than your situation, so I added simpler test (test_named_simple_ctes) with multiple joins

orders = (
region_count.join(
totals.join(Order, region=totals.col.region_id),
region__parent=region_count.col.parent_id
)
.with_cte(totals)
.with_cte(region_count)

from django-cte.

cchavez avatar cchavez commented on July 22, 2024

@millerdev first_with and second_with are not related to each other, it's not a recursive with, they make two different calculation but I want to get both result in one single sql by join them with the Model0.

from django-cte.

cchavez avatar cchavez commented on July 22, 2024

@millerdev thank you for you help, I think I misunderstood the join method and I followed what to mentioned and it's working, it's generating the SQL that I expected.

I did the following:

first_with.join(second_with.join(Modelo0, id=second_with.col.id), id=first_with.col.id).with_cte(first_with).with_cte(second_with)...

And that generate the SQL that I expected, making the Model0 join with both second_with and first_with.

Than you very much for you help.

from django-cte.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.