我收到此错误消息,有人可以就解决方案提出建议吗?
我查看了这个论坛,无法找到解决方案
动态SQL错误
中没有为第1列指定列名
SQL错误代码= -104
无效命令
在派生表ACCRG
SELECT DISTINCT locationgroup.name AS MainGroup, product.num AS ProductNumber,
product.description AS ProductDescription, uom.code AS UOM, company.name AS company,
sum(((SELECT SUM(productsSold.qtyfulfilled) FROM soitem productsSold WHERE soitem.id = productsSold.id AND productsSold.productid = product.id) * COALESCE(uomconversion.multiply,1)) / COALESCE(uomconversion.factor,1)) AS uomqty
FROM soitem
LEFT OUTER JOIN so ON (so.id = soitem.soid)
LEFT OUTER JOIN product ON (soitem.productid = product.id)
LEFT OUTER JOIN uom ON (product.uomid = uom.id)
LEFT OUTER JOIN locationgroup ON (so.locationgroupid = locationgroup.id)
LEFT OUTER JOIN qbclass ON (qbclass.id = soitem.qbclassid)
LEFT OUTER JOIN customer ON (customer.id = so.customerid)
LEFT JOIN (SELECT max(accountgrouprelation.id) AS relationID, accountgrouprelation.accountid
FROM accountgrouprelation
LEFT JOIN accountGroup ON accountGroupRelation.groupId = accountGroup.id
WHERE UPPER(COALESCE (accountgroup.name, '%')) LIKE UPPER('%')
GROUP BY 2) accrg ON customer.accountid = accrg.accountid
LEFT JOIN accountgrouprelation ON accrg.relationid = accountgrouprelation.id
LEFT OUTER JOIN accountgroup ON (accountgroup.id = accountgrouprelation.groupid)
LEFT OUTER JOIN uomconversion ON ((product.uomid = uomconversion.touomid) AND (soitem.uomid = uomconversion.fromuomid))
JOIN company ON company.id = 1
WHERE soitem.qtyfulfilled > 0
AND soitem.typeid in (10,12,80)
AND locationgroup.id IN (1,2,3,4)
AND qbclass.id LIKE '%'
AND UPPER(so.salesman) LIKE UPPER('%')
AND UPPER(COALESCE (accountgroup.name, '%')) LIKE UPPER('%')
AND soitem.datelastfulfillment BETWEEN '2015-11-30 23:59:59.0' AND '2015-12-31 23:59:59.0'
GROUP BY maingroup, productnumber, productdescription, uom, company
ORDER BY 1,product.num ASCENDING
答案 0 :(得分:1)
信不信由你,我认为错误来自你的ORDER BY
陈述:
ORDER BY 1,product.num ASCENDING
我认为ORDER BY
MySQL中的常数不合法。由错误讲述,似乎MySQL正试图在1
派生表中找到一个名为ACCRG
的列。没有这样的列,因此您收到此错误。相反,为什么不只是ORDER BY
产品编号?:
ORDER BY product.num ASCENDING