查询表达式中的Ms-access语法错误(缺少运算符)'(Quantity * UnitPrice)ExtendedPrice'

时间:2018-01-19 09:14:31

标签: c# sql ms-access

OleDbConn.ole = "SELECT ProductCode, Description, Quantity, UnitPrice, (Quantity * UnitPrice) ExtendedPrice FROM SalesReturnItem sri INNER JOIN Product p ON p.ProductNo = sri.ProductID WHERE Sri.InvoiceNo = " 
+ invoiceNo + " ORDER BY Description ";

每当我执行此查询时,我都会收到以下错误 -

  

查询表达式中的语法错误(缺少运算符)'(数量*   UnitPrice)ExtendedPrice'。

请帮助

1 个答案:

答案 0 :(得分:1)

使用AS - SQL别名用于为表或列中的列提供临时名称。

OleDbConn.ole = "SELECT ProductCode, Description, Quantity, UnitPrice, (Quantity * UnitPrice) AS ExtendedPrice FROM SalesReturnItem sri INNER JOIN Product p ON p.ProductNo = sri.ProductID WHERE Sri.InvoiceNo = " 
+ invoiceNo + " ORDER BY Description ";