开发者社区 问答 正文

SQL解决问题

表test
screenshot
查询后的结果
screenshot
求SQL语句

展开
收起
吴孟桥 2016-06-12 15:44:52 2176 分享 版权
1 条回答
写回答
取消 提交回答
  • screenshot
    思路跟你求第三列是一样的,但是这里把你的select id,store,(select SUM(store) from test b where b.ID<=a.ID ) from test a这句查询的结果集当做表来替代test表,相当于又嵌套了一层查询
    select id,store,store1,(select SUM(store1) from tttt b where b.ID<=a.ID ) store2 from tttt a就是这里的tttt由你那句替换。

    2019-07-17 19:34:18
    赞同 展开评论
问答分类:
SQL
问答标签:
问答地址:
相关问答
755
0
0
595
0
0
1387
1
0
1328
1
0
2217
1
0
3705
1
0