12
返回列表 发新帖
楼主: declare64

[SQL] 创建view的语句如何实现sum前几个月的结果

[复制链接]
论坛徽章:
520
奥运会纪念徽章:垒球
日期:2008-09-15 01:28:12生肖徽章2007版:鸡
日期:2008-11-17 23:40:58生肖徽章2007版:马
日期:2008-11-18 05:09:48数据库板块每日发贴之星
日期:2008-11-29 01:01:02数据库板块每日发贴之星
日期:2008-12-05 01:01:03生肖徽章2007版:虎
日期:2008-12-10 07:47:462009新春纪念徽章
日期:2009-01-04 14:52:28数据库板块每日发贴之星
日期:2009-02-08 01:01:03生肖徽章2007版:蛇
日期:2009-03-09 22:18:532009日食纪念
日期:2009-07-22 09:30:00
11#
发表于 2021-7-12 21:24 | 只看该作者
jihuyao 发表于 2021-6-26 03:55
A little bit odd but you can build your own dimension table with columns my_month, start, end and cr ...

你这是啥意思?"input" 是怎么传递给视图的?

使用道具 举报

回复
论坛徽章:
520
奥运会纪念徽章:垒球
日期:2008-09-15 01:28:12生肖徽章2007版:鸡
日期:2008-11-17 23:40:58生肖徽章2007版:马
日期:2008-11-18 05:09:48数据库板块每日发贴之星
日期:2008-11-29 01:01:02数据库板块每日发贴之星
日期:2008-12-05 01:01:03生肖徽章2007版:虎
日期:2008-12-10 07:47:462009新春纪念徽章
日期:2009-01-04 14:52:28数据库板块每日发贴之星
日期:2009-02-08 01:01:03生肖徽章2007版:蛇
日期:2009-03-09 22:18:532009日食纪念
日期:2009-07-22 09:30:00
12#
发表于 2021-7-13 02:42 | 只看该作者
从回复时间来看,楼上几位的发帖都被关小黑屋了,如果以后碰到这种情况给我发个站内PM, 要不然可能要关很久。

使用道具 举报

回复
论坛徽章:
0
13#
发表于 2021-7-13 03:39 | 只看该作者
used term for function like binding parameter for SQL.  Exactly, create the view as described using cross join/where/group and then return the requested month sum,

select c1, ..., sum_val from grouped_view whre my_month='202107' ;

--create month dimension table or view with  (col my_month, start, end)
--create grouped_view as select t1.c1, ..., t2.my_month, sum(t1.val) sum_val from t1, dim_month t2 where t1.month between t2.start and t2.end group by t1.c1, ...,  t2.my_month ;

使用道具 举报

回复
论坛徽章:
13
2010新春纪念徽章
日期:2010-03-01 11:04:59技术图书徽章
日期:2018-03-01 10:21:49秀才
日期:2018-03-01 10:21:252015年新春福章
日期:2015-03-06 11:58:18喜羊羊
日期:2015-03-04 14:52:46优秀写手
日期:2014-04-22 06:00:18马上有对象
日期:2014-02-18 16:44:082014年新春福章
日期:2014-02-18 16:44:082013年新春福章
日期:2013-02-25 14:51:242012新春纪念徽章
日期:2012-01-04 11:56:01
14#
发表于 2021-7-13 11:22 | 只看该作者
newkid 发表于 2021-7-12 08:21
就以楼主的例子来创建一个管道函数:create table table1 (col1 number,col2 number, col3 number, col4 nu ...

谢谢。

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表