1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
CO_RQT_LOTS_RECA :=
' select ' +
' right(''0'' + cast(TABLE040.SEQ_RAY as varchar(2)),2) as SEQ_RAY, ' +
' TABLE170.SEQ_FAM as SEQ_FAM, ' +
' (select ' +
' isnull(sum(T640INT.QTE_COMPTEE),0) ' +
' from ' +
' TABLE640 T640INT with (nolock) ' +
' join TABLE030 T030INT with (nolock) on (T640INT.ID_REF_PVT = T030INT.ID_REF_PVT and T640INT.ID_IT = T030INT.ID_IT) ' +
' join TABLE310 T310INT with (nolock) on T030INT.ID_REF_PVT = T310INT.ID_REF_PVT ' +
' join TABLE170 T170INT with (nolock) on (T310INT.ID_ENS = T170INT.ID_ENS and T310INT.SEQ_FAM_RAT = T170INT.SEQ_FAM) ' +
' join TABLE380 T380INT with (nolock) on (T170INT.ID_ENS = T380INT.ID_ENS and T170INT.SEQ_TRIBU = T380INT.SEQ_TRIBU) ' +
' join TABLE040 T040INT with (nolock) on (T380INT.ID_ENS = T040INT.ID_ENS and T380INT.SEQ_CHEF_PDT = T040INT.SEQ_CHEF_PDT) ' +
' where ' +
' T310INT.FLAG_TOP_SOLDE = 0 ' +
' and T310INT.ID_LR = :IdLr1 ' +
' and T640INT.DateTraitement = :DateTraitement2 ' +
' and T170INT.SEQ_FAM = TABLE170.SEQ_FAM ' +
' and T040INT.SEQ_RAY = TABLE040.SEQ_RAY) as QTE_COMPTEE, ' +
' (select ' +
' isnull(sum(T640INT.QTE_COMPTEE * T030INT.PRIX_VENTE),0) ' +
' from ' +
' TABLE640 T640INT with (nolock) ' +
' join TABLE030 T030INT with (nolock) on (T640INT.ID_REF_PVT = T030INT.ID_REF_PVT and T640INT.ID_IT = T030INT.ID_IT) ' +
' join TABLE310 T310INT with (nolock) on T030INT.ID_REF_PVT = T310INT.ID_REF_PVT ' +
' join TABLE170 T170INT with (nolock) on (T310INT.ID_ENS = T170INT.ID_ENS and T310INT.SEQ_FAM_RAT = T170INT.SEQ_FAM) ' +
' join TABLE380 T380INT with (nolock) on (T170INT.ID_ENS = T380INT.ID_ENS and T170INT.SEQ_TRIBU = T380INT.SEQ_TRIBU) ' +
' join TABLE040 T040INT with (nolock) on (T380INT.ID_ENS = T040INT.ID_ENS and T380INT.SEQ_CHEF_PDT = T040INT.SEQ_CHEF_PDT) ' +
' where' +
' T310INT.FLAG_TOP_SOLDE = 0 ' +
' and T310INT.ID_LR = :IdLr2 ' +
' and T640INT.DateTraitement = :DateTraitement2 ' +
' and T170INT.SEQ_FAM = TABLE170.SEQ_FAM ' +
' and T040INT.SEQ_RAY = TABLE040.SEQ_RAY) as VALEUR, ' +
' (select ' +
' isnull(sum(T640INT.QTE_COMPTEE),0) ' +
' from ' +
' TABLE640 T640INT with (nolock) ' +
' join TABLE030 T030INT with (nolock) on (T640INT.ID_REF_PVT = T030INT.ID_REF_PVT and T640INT.ID_IT = T030INT.ID_IT) ' +
' join TABLE310 T310INT with (nolock) on T030INT.ID_REF_PVT = T310INT.ID_REF_PVT ' +
' join TABLE170 T170INT with (nolock) on (T310INT.ID_ENS = T170INT.ID_ENS and T310INT.SEQ_FAM_RAT = T170INT.SEQ_FAM) ' +
' join TABLE380 T380INT with (nolock) on (T170INT.ID_ENS = T380INT.ID_ENS and T170INT.SEQ_TRIBU = T380INT.SEQ_TRIBU) ' +
' join TABLE040 T040INT with (nolock) on (T380INT.ID_ENS = T040INT.ID_ENS and T380INT.SEQ_CHEF_PDT = T040INT.SEQ_CHEF_PDT) ' +
' where ' +
' T310INT.FLAG_TOP_SOLDE = 1 ' +
' and T310INT.ID_LR = :IdLr3 ' +
' and T640INT.DateTraitement = :DateTraitement3 ' +
' and T170INT.SEQ_FAM = TABLE170.SEQ_FAM ' +
' and T040INT.SEQ_RAY = TABLE040.SEQ_RAY) as QTE_SOLDE, ' +
' (select ' +
' isnull(sum(T640INT.QTE_COMPTEE * T030INT.PRIX_VENTE),0) ' +
' from ' +
' TABLE640 T640INT with (nolock) ' +
' join TABLE030 T030INT with (nolock) on (T640INT.ID_REF_PVT = T030INT.ID_REF_PVT and T640INT.ID_IT = T030INT.ID_IT) ' +
' join TABLE310 T310INT with (nolock) on T030INT.ID_REF_PVT = T310INT.ID_REF_PVT ' +
' join TABLE170 T170INT with (nolock) on (T310INT.ID_ENS = T170INT.ID_ENS and T310INT.SEQ_FAM_RAT = T170INT.SEQ_FAM) ' +
' join TABLE380 T380INT with (nolock) on (T170INT.ID_ENS = T380INT.ID_ENS and T170INT.SEQ_TRIBU = T380INT.SEQ_TRIBU) ' +
' join TABLE040 T040INT with (nolock) on (T380INT.ID_ENS = T040INT.ID_ENS and T380INT.SEQ_CHEF_PDT = T040INT.SEQ_CHEF_PDT) ' +
' where ' +
' T310INT.FLAG_TOP_SOLDE = 1 ' +
' and T310INT.ID_LR = :IdLr4 ' +
' and T640INT.DateTraitement = :DateTraitement4 ' +
' and T170INT.SEQ_FAM = TABLE170.SEQ_FAM ' +
' and T040INT.SEQ_RAY = TABLE040.SEQ_RAY) as VALEUR_S, ' +
' isnull(sum(TABLE640.QTE_COMPTEE),0) as TOT_QTE, ' +
' isnull(sum(TABLE640.QTE_COMPTEE * TABLE030.PRIX_VENTE),0) as TOT_VALEUR ' +
' ' +
' from ' +
' TABLE640 with (nolock) ' +
' join TABLE030 with (nolock) on (TABLE640.ID_REF_PVT = TABLE030.ID_REF_PVT and TABLE640.ID_IT = TABLE030.ID_IT) ' +
' join TABLE310 with (nolock) on TABLE030.ID_REF_PVT = TABLE310.ID_REF_PVT ' +
' join TABLE170 with (nolock) on (TABLE310.ID_ENS = TABLE170.ID_ENS and TABLE310.SEQ_FAM_RAT = TABLE170.SEQ_FAM) ' +
' join TABLE380 with (nolock) on (TABLE170.ID_ENS = TABLE380.ID_ENS and TABLE170.SEQ_TRIBU = TABLE380.SEQ_TRIBU) ' +
' join TABLE040 with (nolock) on (TABLE380.ID_ENS = TABLE040.ID_ENS and TABLE380.SEQ_CHEF_PDT = TABLE040.SEQ_CHEF_PDT) ' +
' ' +
' where ' +
' TABLE640.DateTraitement = :DateTraitement5 ' +
' and TABLE310.ID_LR = :IdLr5 ' +
' ' +
' group by ' +
' TABLE040.SEQ_RAY, ' +
' TABLE170.SEQ_FAM ' +
' ' +
' order by ' +
' TABLE040.SEQ_RAY, ' +
' TABLE170.SEQ_FAM '; |
Partager