title: Qlik Sense : SQL With Statement
body: <p>I'm using Qlik Sense Desktop in order to create reportings.
  However, i want to load datas using this request : </p>
  
  <pre><code>WITH ventes AS (SELECT        Reservations.re_numero AS IDSession, InscriptionsLignes.il_montantLigneHT AS VenteSession, Reservations.re_nom AS NomSession, Tiers.ti_nom AS NomClient, CASE WHEN Tiers_2.ti_nom + ' ' + Tiers_2.ti_prenom IS NULL THEN 'Non affecté' ELSE Tiers_2.ti_nom + ' ' + Tiers_2.ti_prenom END AS NomCommercial
                                       FROM            Reservations INNER JOIN
                                                                 InscriptionsEntetes ON Reservations.re_numero = InscriptionsEntetes.in_reservation INNER JOIN
                                                                 InscriptionsLignes ON InscriptionsEntetes.in_numero = InscriptionsLignes.il_inscription INNER JOIN
                                                                 InscriptionsTiers ON InscriptionsEntetes.in_numero = InscriptionsTiers.it_inscription AND InscriptionsLignes.il_inscription = InscriptionsTiers.it_inscription INNER JOIN
                                     Tiers ON InscriptionsTiers.it_tiers = Tiers.ti_identifiant LEFT OUTER JOIN
                                     Tiers AS Tiers_2 ON InscriptionsEntetes.in_idTiersConseiller = Tiers_2.ti_identifiant
                                       WHERE        (InscriptionsTiers.it_typeRattachement = '01') AND (Reservations.re_etat &lt;&gt; 3) AND (Reservations.re_annulation = 0) AND (InscriptionsEntetes.in_Etat &lt;&gt; '4')), couts AS
      (SELECT        Reservations_1.re_numero AS IDSession, ReservationsProduits.rp_montantPrevu AS Couts
        FROM            Reservations AS Reservations_1 INNER JOIN
                                  ReservationsProduits ON Reservations_1.re_numero = ReservationsProduits.rp_numeroReservation
        WHERE        (Reservations_1.re_etat &lt;&gt; 3) AND (Reservations_1.re_annulation = 0)), tot_couts AS
      (SELECT        IDSession, SUM(Couts) AS couts_total
        FROM            couts AS couts_1
        GROUP BY IDSession), tot_ventes AS
      (SELECT        IDSession, SUM(VenteSession) AS ventes_total
        FROM            ventes AS ventes_1
        GROUP BY IDSession)
      SELECT        tvn.IDSession, tvn.ventes_total, tct.couts_total, ventes_2.NomSession, ventes_2.NomClient, ventes_2.VenteSession, ventes_2.VenteSession - tct.couts_total / (tvn.ventes_total / ventes_2.VenteSession) AS marge
       FROM            tot_ventes AS tvn INNER JOIN
                                tot_couts AS tct ON tvn.IDSession = tct.IDSession INNER JOIN
                                ventes AS ventes_2 ON tvn.IDSession = ventes_2.IDSession
       WHERE        (ventes_2.VenteSession &lt;&gt; 0)
       ORDER BY tvn.IDSession
  </code></pre>
  
  <p>As you can see, I'm using the SQL With Statement but it doesn't work on Qlik, "With" is a unknown statement they said</p>
  
  <p>Anyone can help me ?  </p>