1,747
社区成员
发帖
与我相关
我的任务
分享
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[test](
[_id] [int] IDENTITY(1,1) NOT NULL,
[Name] [varchar](50) NOT NULL,
[Amount] [decimal](18, 4) NOT NULL,
[Addr] [varchar](50) NOT NULL,
[Amount2] [decimal](18, 4) NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
INSERT test(Name,Amount,Addr,Amount2) VALUES('A1',11,'CN',0.1)
INSERT test(Name,Amount,Addr,Amount2) VALUES('A1',12,'US',0.2)
INSERT test(Name,Amount,Addr,Amount2) VALUES('A1',13,'US',0.3)
INSERT test(Name,Amount,Addr,Amount2) VALUES('A2',14,'CN',0.4)
INSERT test(Name,Amount,Addr,Amount2) VALUES('A2',15,'US',0.5)
SELECT Name,Addr,SUM(Amount),SUM(Amount2) FROM test GROUP BY Name,Addr
db.createCollection("test")
db.test.remove({"_id":{"$ne":"10"}})
db.test.insert({Name:"A1",Amount:11,Addr:"CN",Amount2:0.1})
db.test.insert({Name:"A1",Amount:12,Addr:"US",Amount2:0.2})
db.test.insert({Name:"A1",Amount:13,Addr:"US",Amount2:0.3})
db.test.insert({Name:"A2",Amount:14,Addr:"CN",Amount2:0.4})
db.test.insert({Name:"A2",Amount:15,Addr:"US",Amount2:0.5})