如何使用算术运算执行sql查询并计算结果
例如:
DATEDIFF('2016-10-25', '2016-10-5') AS DiffDate *
(SELECT package_fee) from table_name
package_fee = 10的值
所以操作是dateiff乘以package_fee
答案 0 :(得分:2)
我假设您希望日期差异中的天数为
DATEDIFF('2016-10-25', '2016-10-5')
无效(至少在TSQL中):
SELECT package_fee * DATEDIFF(DAY, '2016-10-25', '2016-10-5') AS result
FROM table_name