The below view runs fine when executed, but when I try to open it in design mode, it returns a parsing error as: "The following errors were encountered while parsing the contents of the SQL pane."
Error in FROM clause: near 'VALUES'.
Error in FROM clause: near ')'.
Unable to parse query text.
SELECT
CONCAT(q.QuotationNo, ' Rev ', q.QuotRevNo) AS QNo
, q.LastStatus AS Status
, q.IsProject AS Type
, CASE
WHEN q.IsProject = 1
THEN 'M'
WHEN q.IsProject = 2
THEN 'P'
ELSE 'D'
END AS [Product Type]
, (SELECT
MIN([Intake Date])
FROM
(VALUES
(q.ORDate)
,(q.PIDate)
,(q.PODate)
,(q.SentTo)
,(q.OCDate)
,(q.ShipDate)
,(q.INVDate)
,(q.INVPaymentDate)) AS AllDate([Intake Date])) AS [Intake Date]
, p.TotalOfItem AS Sales
, c.CompanyName AS Customer
, w.LastFirstName AS Contact
, v.CompanyName AS Vendor
FROM
dbo.tblQuotations q
INNER JOIN
dbo.tblProducts p
ON q.QuotationID = p.QuotationID
LEFT OUTER JOIN
dbo.tblCompany c
ON c.CompanyID = q.CompanyID
LEFT OUTER JOIN
dbo.tblWContacts w
ON q.QuotConID = w.ConID
LEFT OUTER JOIN
dbo.tblCompany v
ON q.SupplierID = v.CompanyID
WHERE q.StatusCode IN (4, 5, 6, 7, 8, 9)
How to prevent the error. error message
Making an educated guess this is SQL Server, given the [delimited aliases], you could try replacing the sub-query with an
apply(). Generally the best advice is to steer clear of the visual designer, it's not particularly robust.This is untested of course but hopefully conveys the idea: