有其他方法连接这些表吗



我想加入表[Header]和[Line],以便在ssdt上填充事实数据表,我收到了错误消息,告诉我所有列的语法都不正确

select
concat ([Document No_],[Line No_]) as [InterventionLigne],
case H.Status
when 0 then ''
when 1 then 'Non Traité'
when 2 then 'Intervention'
when 3 then 'Rép. en Instance'
when 4 then 'Rép. en cours'
when 5 then 'Liv. en Instance'
when 6 then 'Liv. en cours'
when 7 then 'Email envoyé'
when 8 then 'Pickup Magasin'
when 9 then 'Arrivé a IRC'
when 10 then 'Transfert au CTA'
when 11 then 'Retour du CTA'
when 12 then 'Retour au magasin'
when 13 then 'Livraison'
end as Statut
[No_ Document Externe] as [Num_ Document Externe],
H.[Nom],
H.[Adresse Contact],
H.[Ville],
[Commentaire],
[Sources Réclamations],
[Date Reclamation],
[Designation],
case H.Saved
when 0 then 'Non'
when 1 then 'Oui'
end as Enregist,
case H.Validated
when 0 then 'Non'
when 1 then 'Oui'
end as Validé,
[USER] as [Utilisateur],
case H.[Type Intervention]
when 0 then ''
when 1 then 'Direct'
when 2 then 'Via Un Partenaire'
end as [Type_Intervention],
[Partenaire],[Année garantie], case H.NonEdit
when 0 then 'Non'
when 1 then 'Oui'
end as [NonEdit],
[Magasin],[Emplacement],[En Garantie],[Job No_],[Document No_] as [Document Num_],
[Line No_] as[Line Num_],
[Type Travaux],[Starting Date] as [DateDébut],
[Travaux effectués],
[Libellé],
l.[technicien],
[Remarque],
[Rémunération]
from [dbo].[Header$] H left join [dbo].[Line$] L
on H.[No_ Document]=L.[Document No_]

错误:Syntaxe错误通过"No_ Document Externe">

和我在所有列中都得到相同的错误。

Statut:后缺少逗号

case H.Status
when 0 then ''
when 1 then 'Non Traité'
when 2 then 'Intervention'
when 3 then 'Rép. en Instance'
when 4 then 'Rép. en cours'
when 5 then 'Liv. en Instance'
when 6 then 'Liv. en cours'
when 7 then 'Email envoyé'
when 8 then 'Pickup Magasin'
when 9 then 'Arrivé a IRC'
when 10 then 'Transfert au CTA'
when 11 then 'Retour du CTA'
when 12 then 'Retour au magasin'
when 13 then 'Livraison'
end as Statut
[No_ Document Externe] as [Num_ Document Externe],

您需要在所有命令名后面加一个逗号。关于环绕列名的[],使用它们是正确的,请参阅https://www.sqlshack.com/how-to-write-sql-queries-with-spaces-in-column-names/

编辑

这是一个在select子句中的字段之间添加逗号的查询:

select
concat ([Document No_],[Line No_]) as [InterventionLigne],
case H.Status
when 0 then ''
when 1 then 'Non Traité'
when 2 then 'Intervention'
when 3 then 'Rép. en Instance'
when 4 then 'Rép. en cours'
when 5 then 'Liv. en Instance'
when 6 then 'Liv. en cours'
when 7 then 'Email envoyé'
when 8 then 'Pickup Magasin'
when 9 then 'Arrivé a IRC'
when 10 then 'Transfert au CTA'
when 11 then 'Retour du CTA'
when 12 then 'Retour au magasin'
when 13 then 'Livraison'
end as Statut,
[No_ Document Externe] as [Num_ Document Externe],
H.[Nom],
H.[Adresse Contact],
H.[Ville],
[Commentaire],
[Sources Réclamations],
[Date Reclamation],
[Designation],
case H.Saved
when 0 then 'Non'
when 1 then 'Oui'
end as Enregist,
case H.Validated
when 0 then 'Non'
when 1 then 'Oui'
end as Validé,
[USER] as [Utilisateur],
case H.[Type Intervention]
when 0 then ''
when 1 then 'Direct'
when 2 then 'Via Un Partenaire'
end as [Type_Intervention],
[Partenaire],[Année garantie], case H.NonEdit
when 0 then 'Non'
when 1 then 'Oui'
end as [NonEdit],
[Magasin],[Emplacement],[En Garantie],[Job No_],[Document No_] as [Document Num_],
[Line No_] as[Line Num_],
[Type Travaux],[Starting Date] as [DateDébut],
[Travaux effectués],
[Libellé],
l.[technicien],
[Remarque],
[Rémunération]
from [dbo].[Header$] H left join [dbo].[Line$] L
on H.[No_ Document]=L.[Document No_]

请告诉我它现在是否对你更有效。

最新更新