Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

怎么解决sequelize会在order中那个参数自动加上表的别名

$
0
0

code

attributes: [
                sequelize.literal('SUM(stock) AS stock'),
                sequelize.literal('SUM(actualAmount) AS actualAmount'),
                sequelize.literal('SUM(differAmount) AS differAmount'),
                sequelize.literal('SUM(beforeInventorySum) AS beforeInventorySum'),
                sequelize.literal('SUM(afterInventorySum) AS afterInventorySum')
            ],
            group: 'GoodId',
            order: ['differAmount','desc']

sql

SELECT
	SUM(stock) AS stock,
	SUM(actualAmount) AS actualAmount,
	SUM(differAmount) AS differAmount,
	SUM(beforeInventorySum) AS beforeInventorySum,
	SUM(afterInventorySum) AS afterInventorySum
FROM
	`inventory_result_details` AS `InventoryResultDetail`
GROUP BY
	GoodId
ORDER BY
	`InventoryResultDetail`.`differAmount` DESC

sequelize版本3.2,我想针对分组后的数据再排序,sequelize会在order中那个参数自动加上表的别名,导致数据有问题


Viewing all articles
Browse latest Browse all 14821

Trending Articles