我想实现下面计算的值 ,这个SQL 如何写呢?
1 2.88/0.32
2 3.99/2.88
3 6.39/3.99
1 9
2 1.38
3 1.60
下面是表结构和表数据,用于测试。
if exists (select * from sysobjects where id = OBJECT_ID('[GP_GPDMB_TMP9]') and OBJECTPROPERTY(id, 'IsUserTable') = 1)
DROP TABLE [GP_GPDMB_TMP9]
CREATE TABLE [GP_GPDMB_TMP9] (
[序号] [bigint] NULL,
[AA] [decimal] (18,2) NULL,
[BB] [decimal] (18,2) NULL,
[CC] [varchar] (50) NULL)
INSERT [GP_GPDMB_TMP9] ([序号],[AA],[BB],[CC]) VALUES ( 1,0.32,0.97,N'001')
INSERT [GP_GPDMB_TMP9] ([序号],[AA],[BB],[CC]) VALUES ( 2,2.88,2.41,N'002')
INSERT [GP_GPDMB_TMP9] ([序号],[AA],[BB],[CC]) VALUES ( 3,3.99,5.68,N'003')
INSERT [GP_GPDMB_TMP9] ([序号],[AA],[BB],[CC]) VALUES ( 4,6.39,8.35,N'004')