2017-05-16 14 views
1

Qlik Sense Desktopを使用してレポートを作成しています。 は、しかし、私はこの要求を使用して件のデータをロードしたい:Qlik Sense:ステートメント付きSQL

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 <> 3) AND (Reservations.re_annulation = 0) AND (InscriptionsEntetes.in_Etat <> '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 <> 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 <> 0) 
    ORDER BY tvn.IDSession 

あなたが見ることができるように、彼らは言った、未知のステートメントである「と」、私は声明でSQLを使用していますが、それはQlik上では動作しません。

誰でも手伝ってもらえますか?

答えて

0

あなたは親のいずれかであなたのクエリをカプセル化することができます

TableName: 
Load *; 
SQL 
select * 
from (
    --put your WITH query here 
) as temp; 

あなたのRDBMSによっては、あなたが(「TEMPなど」)は、この最後のエイリアスを必要としない場合があります。

関連する問題