您可以将Union查询的结果与另一列的SUM合并吗?

时间:2015-11-30 14:59:13

标签: php mysql

即使Quantity列为decimal(10,4)price列为decimal(8,2),此语句是否正常?

"(SELECT `price` FROM `"
.$this->symbol."Trades` ORDER BY `TS` DESC LIMIT 1) UNION (SELECT "
."`price` FROM `".$this->symbol."Trades` WHERE `TS` >="
." DATE_SUB(NOW(), INTERVAL 1 DAY) ORDER BY `TS` ASC LIMIT 1) UNION"
." (SELECT SUM(`Quantity`) AS volume FROM `".
$this->symbol."Trades` WHERE `TS` >= DATE_SUB(NOW(), INTERVAL 1 DAY))" 

0 个答案:

没有答案