案例

时间:2018-04-06 09:15:28

标签: sql-server sql-server-2008

我试图运行此查询,但在case和mySum附近我的语法不正确

Select 
    sum(sumTotal) as mySum 
from
    customertrans 
where 
    DateTime >= DATEPART(HOUR, '6:00')
    case when mySum >25 
    then update TopStatistics 
         set SumDelivery = mySum

2 个答案:

答案 0 :(得分:0)

你正在尝试的是不可能的。这应该有效:

;with cte (mySum) as 
(
    Select sum(sumTotal) as mySumTopStatistics 
    from customertrans 
    where  DateTime >= DATEPART(HOUR, '6:00')

)
update TopStatistics
set SumDelivery = mySum
where <Search condition with cte table>

答案 1 :(得分:-1)

不确定您的目标,但我认为您需要两个步骤:

root, ext = os.path.splitext(path)
if not ext:
   ext = '.npy'
path = root + ext

然后根据以上输出进行更新。