我是sql server
的新人,写下这个问题:
SELECT top 20 y.Telno,
t.Cycle+'-'+y.Cycle Cycle,
((y.CurBill - t.CurBill)/y.CurBill) Price
FROM [ClubEatc].[dbo].[GetOnlineBills] y
INNER JOIN [ClubEatc].[dbo].[GetOnlineBills] t
ON y.Telno = t.TelNo AND CAST(y.Cycle as int)-1 = CAST(t.Cycle as int)
在实际数据中GetOnlineBills
Cycle=952
中有TelNo CurBill TotalBill ExecuteDate Cycle
4133223011 43 1209337 1395/4/21 952
的记录:
Cycle=951
并在TelNo CurBill TotalBill ExecuteDate Cycle
4133223011 349 1209295 1395/4/21 951
:
calc
在计算(Curbill.Cycle[952]-Curbill.Cycle[951])/Curbill.Cycle[952]=((349-43))/349=0.87
这个公式:
-7.11627906976744
但是查询显示给我:
#if __IPHONE_OS_VERSION_MAX_ALLOWED <= __IPHONE_9_3
#define CBManagerState CBCentralManagerState
#define CBManagerStateUnknown CBCentralManagerStateUnknown
#define CBManagerStateResetting CBCentralManagerStateResetting
#define CBManagerStateUnsupported CBCentralManagerStateUnsupported
#define CBManagerStateUnauthorized CBCentralManagerStateUnauthorized
#define CBManagerStatePoweredOff CBCentralManagerStatePoweredOff
#define CBManagerStatePoweredOn CBCentralManagerStatePoweredOn
#endif
发生了什么?我错了?感谢所有人。
答案 0 :(得分:1)
你的代码正在做((43-349))/ 43并给出结果 -
使用以下代码...
SELECT top 20 y.Telno,
t.Cycle+'-'+y.Cycle Cycle,
((t.CurBill - y.CurBill)/t.CurBill) Price FROM [ClubEatc].[dbo].[GetOnlineBills] y INNER JOIN
[ClubEatc].[dbo].[GetOnlineBills] t
ON y.Telno = t.TelNo AND CAST(y.Cycle as int)-1 = CAST(t.Cycle as int)