不幸的是,我是SQL的新手,我使用SQL Server创建非常简单的查询,但我遇到的问题我不确定如何解决...
对于第一个,我必须注释掉日期才能使它工作,否则一切都是空白的......
SELECT
VendorName, InvoiceNumber, InvoiceDate, InvoiceTotal
FROM
Vendors
JOIN
Invoices ON Vendors.VendorID = Invoices.VendorID
WHERE
InvoiceDate < 6/1/2008
ORDER BY
VendorName;
第二个列有一个额外的列,我不知道如何摆脱。
SELECT
InvoiceNumber, VendorName, InvoiceDate
FROM
Vendors AS v
JOIN
Invoices AS i ON v.VendorID = i.VendorID
WHERE
InvoiceTotal > 0;
最后,这个(我的其他查询工作正常)不起作用。它应该加入3个表并按VendorID
按VendorName
排序过滤结果,然后我不断收到此错误:
将varchar值“115,122,123”转换为数据类型int时,转换失败。
SELECT
InvoiceDate, VendorName, InvoiceNumber, InvoiceLineItemAmount
FROM
Vendors
JOIN
Invoices ON Vendors.VendorID = Invoices.VendorID
JOIN
InvoiceLineItems ON Invoices.InvoiceID = InvoiceLineItems.InvoiceID
WHERE
Vendors.VendorID = '115, 122, 123'
ORDER BY
VendorName;
如果有人可以提出任何建议,我们将不胜感激,谢谢......
答案 0 :(得分:2)
答案 1 :(得分:2)
日期比较应如下所示。它符合您的日期数据库格式
WHERE InvoiceDate < '6/1/2008'
要检查范围之间的项目,它将采用以下格式
Vendors.VendorID IN (115, 122, 123)