【发布时间】:2018-01-23 14:26:13
【问题描述】:
我正在为一个 c# 应用程序做一个简单的任务,我想用 SQL 来做所有的数学运算。
我有 1 个名为 xx_MainOeuvre 的表,我对其执行 2 次选择。 :
select xx_TypeMO, xx_pu from xx_MainOeuvre mo
where mo.xx_TypeDuree != 1 and mo.xx_pu != 0
and xx_sysParentId like 'CC1500107'
给我这个:
xx_TypeMO | xx_pu |
==========================
MOI | 45 |
MOV | 34 |
MOE | 50 |
和
select xx_TypeMO, sum(xx_Duree) as TimeSpend
from xx_MainOeuvre
where xx_TypeDuree = 1 and xx_sysParentId like 'CC1500107'
group by xx_TypeMO
女巫给了我这个:
xx_TypeMO | TimeSpend |
=============================
MOI | 4 |
MOV | 12 |
xx_pu 是单价
我想要一个 timeSpend * unitPrice 的结果。
像这样:
xx_TypeMO | RealPrice |
==============================
MOI | 180 (4*45) |
MOV | 408 (12*34)|
可以这样做吗?还是我应该继续使用我的 C# 方法?
谢谢。
【问题讨论】:
-
你的预期输出是什么?
-
@Ravi 我已经添加了预期的输出
-
我个人会收集所有数据并在 C# 中进行计算,因为如果您收集所有数据,您可以在程序的其他地方执行其他计算