但它会在关键字select"附近导致错误"语法,我不明白。请帮助我,告诉我如何在SQL Server中创建视图:
这是查询:
CREATE VIEW commandefournisseur
SELECT
F_LOT.LT_IDENT AS LOT_IDENT
, ISNULL(SUM(LCF_PRIXTOTAL),0) AS PRIX_HT
, .LCF_LICENCE AS AVENANT
, LCF_TAUXTVA AS TAUXTVA
, CF_ETAT AS COTATION
, FF_CODE_DEVISE AS CODE_DEVISE
, BPA_NOM_1 AS BATIMENT
, BPA_ADRESSE_1 AS Adresse
, ISNULL (SUM(FF_SOLDE),0) as Reste
, FF_DATE as dateFact
FROM
F_LIGNECOMFOU
INNER JOIN
F_COMMANDEFOU ON CF_NUMERO = LCF_CF_NUMERO
INNER JOIN
F_LOT ON LCF_LT_IDENT = LT_IDENT
INNER JOIN
F_P_FOURNISSEUR ON CF_IDENT_FO = FOU_IDENT
INNER JOIN
F_FACTURESFOU ON FOU_IDENT = FF_IDENT_FO
INNER JOIN
P_PERSONNE ON FOU_BPP_IDENT = BPP_IDENT
INNER JOIN
P_ADRESSE ON BPA_BPP_IDENT = BPP_IDENT
WHERE
LCF_CODE_AFF = '15330-00'
AND LT_CODE IN ('S82')
GROUP BY
LT_IDENT, LCF_LICENCE, LCF_TAUXTVA, CF_ETAT,
FF_CODE_DEVISE, BPA_NOM_1, BPA_ADRESSE_1, FF_DATE
答案 0 :(得分:7)
您错过了AS
个关键字。
以下是用于在SQL Server中创建视图的标准语法。
SQL Server CREATE VIEW语法
CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition
在你的情况下
CREATE VIEW commandefournisseur AS
SELECT
F_LOT.LT_IDENT AS LOT_IDENT
, ISNULL(SUM(LCF_PRIXTOTAL),0) AS PRIX_HT
, .LCF_LICENCE AS AVENANT
, LCF_TAUXTVA AS TAUXTVA
, CF_ETAT AS COTATION
, FF_CODE_DEVISE AS CODE_DEVISE
, BPA_NOM_1 AS BATIMENT
, BPA_ADRESSE_1 AS Adresse
, ISNULL (SUM(FF_SOLDE),0) as Reste
, FF_DATE as dateFact
FROM
F_LIGNECOMFOU
INNER JOIN
F_COMMANDEFOU ON CF_NUMERO = LCF_CF_NUMERO
INNER JOIN
F_LOT ON LCF_LT_IDENT = LT_IDENT
INNER JOIN
F_P_FOURNISSEUR ON CF_IDENT_FO = FOU_IDENT
INNER JOIN
F_FACTURESFOU ON FOU_IDENT = FF_IDENT_FO
INNER JOIN
P_PERSONNE ON FOU_BPP_IDENT = BPP_IDENT
INNER JOIN
P_ADRESSE ON BPA_BPP_IDENT = BPP_IDENT
WHERE
LCF_CODE_AFF = '15330-00'
AND LT_CODE IN ('S82')
GROUP BY
LT_IDENT, LCF_LICENCE, LCF_TAUXTVA, CF_ETAT,
FF_CODE_DEVISE, BPA_NOM_1, BPA_ADRESSE_1, FF_DATE
答案 1 :(得分:1)