作者:手机用户2502870105 | 来源:互联网 | 2023-05-18 04:25
Unfortunately,IambrandnewtoSQLandamusingSQLServertocreateverysimplequeries,butIam
Unfortunately, I am brand new to SQL and am using SQL Server to create very simple queries, but I am having issues that I am not exactly certain how to work around...
不幸的是,我是SQL的新手,我使用SQL Server创建非常简单的查询,但我遇到的问题我不确定如何解决...
For the first one, I have to comment out the date in order for it to work, otherwise everything is blank...
对于第一个,我必须注释日期才能使它工作,否则一切都是空白的......
SELECT
VendorName, InvoiceNumber, InvoiceDate, InvoiceTotal
FROM
Vendors
JOIN
Invoices ON Vendors.VendorID = Invoices.VendorID
WHERE
InvoiceDate <6/1/2008
ORDER BY
VendorName;
The 2nd one has an extra column that I am not sure how to get rid of.
第二个有一个额外的列,我不知道如何摆脱。
SELECT
InvoiceNumber, VendorName, InvoiceDate
FROM
Vendors AS v
JOIN
Invoices AS i ON v.VendorID = i.VendorID
WHERE
InvoiceTotal > 0;
And lastly, This one (my other queries work fine) is not working. It is supposed to be joining 3 tables and filtering the results by VendorID
sorting by VendorName
, then I keep getting this error:
最后,这个(我的其他查询工作正常)不起作用。它应该是加入3个表并按VendorID按VendorName排序过滤结果,然后我不断收到此错误:
Conversion failed when converting the varchar value '115, 122, 123' to data type int.
将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;
If anyone can please offer any suggestions, it would be much appreciated, thank you...
如果有人可以提供任何建议,我将不胜感激,谢谢......
2 个解决方案