s*u
2 楼
一半pleather, 一半cotton canvas,谢谢观赏:P
i*7
3 楼
SQL 2008
有这样一个table:
phonenum calltime rowID
1 2/4/2010 1
4 2/8/2010 2
2 6/18/2010 3
2 6/20/2010 5
3 8/20/2010 6
4 2/9/2010 7
4 2/11/2010
… … …
我现在要做一个report,就是显示每个phonenum每天收到多少个call,只需要显示前90天
.比如phone1的第一个call是2/4.从那天开始的往后90天,每天收到多少个call.phone4
的第一个call是2/8.那么分别是day1有一个call, day2有一个call,day4有一个call.
具体report的格式如下.
phonenum 1st day 2nd day 3rd day 4th day … 90th day
1 1
2 1 1
3 1
4 1 1 1
有没有大牛知道这个怎么做?
谢谢!
有这样一个table:
phonenum calltime rowID
1 2/4/2010 1
4 2/8/2010 2
2 6/18/2010 3
2 6/20/2010 5
3 8/20/2010 6
4 2/9/2010 7
4 2/11/2010
… … …
我现在要做一个report,就是显示每个phonenum每天收到多少个call,只需要显示前90天
.比如phone1的第一个call是2/4.从那天开始的往后90天,每天收到多少个call.phone4
的第一个call是2/8.那么分别是day1有一个call, day2有一个call,day4有一个call.
具体report的格式如下.
phonenum 1st day 2nd day 3rd day 4th day … 90th day
1 1
2 1 1
3 1
4 1 1 1
有没有大牛知道这个怎么做?
谢谢!
m*g
4 楼
汤圆元宵一起吃,
j*8
8 楼
很美貌!
c*e
9 楼
先做一个辅助table
select phonenum ,
min(calltime) as min_calltime
from your_table
group by 1
然后数的时候用case
select a.phonenum ,
count(case when a.calltime between b.min_calltime and b.min_calltime
+ 1
then a.phonenum else null end) as day1_cnt ,
...
from your_table a
join table_above b
on a.phonenum = b.phonenum
group by 1
order by 1 ;
【在 i******7 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: SQL 2008
: 有这样一个table:
: phonenum calltime rowID
: 1 2/4/2010 1
: 4 2/8/2010 2
: 2 6/18/2010 3
: 2 6/20/2010 5
: 3 8/20/2010 6
: 4 2/9/2010 7
: 4 2/11/2010
select phonenum ,
min(calltime) as min_calltime
from your_table
group by 1
然后数的时候用case
select a.phonenum ,
count(case when a.calltime between b.min_calltime and b.min_calltime
+ 1
then a.phonenum else null end) as day1_cnt ,
...
from your_table a
join table_above b
on a.phonenum = b.phonenum
group by 1
order by 1 ;
【在 i******7 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: SQL 2008
: 有这样一个table:
: phonenum calltime rowID
: 1 2/4/2010 1
: 4 2/8/2010 2
: 2 6/18/2010 3
: 2 6/20/2010 5
: 3 8/20/2010 6
: 4 2/9/2010 7
: 4 2/11/2010
i*7
12 楼
谢谢回复.包子送上。
但是这个a.calltime between b.min_calltime and b.min_calltime + 1貌似不work啊
..而且是90天,要写90个case when么?
【在 c*******e 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: 先做一个辅助table
: select phonenum ,
: min(calltime) as min_calltime
: from your_table
: group by 1
: 然后数的时候用case
: select a.phonenum ,
: count(case when a.calltime between b.min_calltime and b.min_calltime
: + 1
: then a.phonenum else null end) as day1_cnt ,
但是这个a.calltime between b.min_calltime and b.min_calltime + 1貌似不work啊
..而且是90天,要写90个case when么?
【在 c*******e 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: 先做一个辅助table
: select phonenum ,
: min(calltime) as min_calltime
: from your_table
: group by 1
: 然后数的时候用case
: select a.phonenum ,
: count(case when a.calltime between b.min_calltime and b.min_calltime
: + 1
: then a.phonenum else null end) as day1_cnt ,
y*9
13 楼
元宵快乐。排~
z*a
14 楼
厉害!
MM哪里买的pleather啊?
针脚很细,应该是用了缝纫机吧?
想自己手工一个MM图上这样的wristlet。。跟买的差不多呀~!赞~
MM哪里买的pleather啊?
针脚很细,应该是用了缝纫机吧?
想自己手工一个MM图上这样的wristlet。。跟买的差不多呀~!赞~
t*e
17 楼
求科普,啥是pleather啊?
g*l
18 楼
这个是最简单的
select phonenum,
DateDiff(dd, '12/31/2009',phonedate)
as DayNumber,
1 as PhoneCount
into PhoneCountTemp
from table
select phonenum,DayNumber, sum(phonecount) as PhoneCount
from PhoneCountTemp
group by phonenum, daynumber
order by phonenum, daynumber
select phonenum,
DateDiff(dd, '12/31/2009',phonedate)
as DayNumber,
1 as PhoneCount
into PhoneCountTemp
from table
select phonenum,DayNumber, sum(phonecount) as PhoneCount
from PhoneCountTemp
group by phonenum, daynumber
order by phonenum, daynumber
s*u
20 楼
Joann有的,就是人造皮吧,仿皮?不是真皮就对了
R*n
22 楼
吃!
l*0
23 楼
赞~~
i*7
24 楼
谢谢.包子送上..
但貌似这个是从1/1开始算第一天,实际上有的电话是从2月1号才收到call.我想以第一
次收到call的时候算第一天,而不是按照日历算.
【在 g***l 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: 这个是最简单的
: select phonenum,
: DateDiff(dd, '12/31/2009',phonedate)
: as DayNumber,
: 1 as PhoneCount
: into PhoneCountTemp
: from table
: select phonenum,DayNumber, sum(phonecount) as PhoneCount
: from PhoneCountTemp
: group by phonenum, daynumber
但貌似这个是从1/1开始算第一天,实际上有的电话是从2月1号才收到call.我想以第一
次收到call的时候算第一天,而不是按照日历算.
【在 g***l 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: 这个是最简单的
: select phonenum,
: DateDiff(dd, '12/31/2009',phonedate)
: as DayNumber,
: 1 as PhoneCount
: into PhoneCountTemp
: from table
: select phonenum,DayNumber, sum(phonecount) as PhoneCount
: from PhoneCountTemp
: group by phonenum, daynumber
i*7
26 楼
哦.我可能没有说清楚.实际上这个calltime的格式是:mm/dd/yyyy hh:mm:ss的.所以觉
得那个+1可能不work.如果格式包括时间,该怎么写呢?
发信人: cheungche (你不乖), 信区: Database
标 题: Re: 请教一下这个report的query应该怎么样写?
发信站: BBS 未名空间站 (Mon Oct 18 18:44:55 2010, 美东)
先做一个辅助table
select phonenum ,
min(calltime) as min_calltime
from your_table
group by 1
然后数的时候用case
select a.phonenum ,
count(case when a.calltime between b.min_calltime and b.min_calltime
+ 1
then a.phonenum else null end) as day1_cnt ,
...
from your_table a
join table_above b
on a.phonenum = b.phonenum
group by 1
order by 1 ;
【在 c*******e 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: 你有91个column,当然要写90个count了
得那个+1可能不work.如果格式包括时间,该怎么写呢?
发信人: cheungche (你不乖), 信区: Database
标 题: Re: 请教一下这个report的query应该怎么样写?
发信站: BBS 未名空间站 (Mon Oct 18 18:44:55 2010, 美东)
先做一个辅助table
select phonenum ,
min(calltime) as min_calltime
from your_table
group by 1
然后数的时候用case
select a.phonenum ,
count(case when a.calltime between b.min_calltime and b.min_calltime
+ 1
then a.phonenum else null end) as day1_cnt ,
...
from your_table a
join table_above b
on a.phonenum = b.phonenum
group by 1
order by 1 ;
【在 c*******e 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: 你有91个column,当然要写90个count了
R*m
27 楼
元宵快乐
g*l
32 楼
我改了,如果把2/1/2010当第一天,就是DATEDIFF(DD,'1/31/2010',PHONEDATE)
c*e
34 楼
你cast成日期不就可以了?
【在 i******7 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: 哦.我可能没有说清楚.实际上这个calltime的格式是:mm/dd/yyyy hh:mm:ss的.所以觉
: 得那个+1可能不work.如果格式包括时间,该怎么写呢?
:
: 发信人: cheungche (你不乖), 信区: Database
: 标 题: Re: 请教一下这个report的query应该怎么样写?
: 发信站: BBS 未名空间站 (Mon Oct 18 18:44:55 2010, 美东)
: 先做一个辅助table
: select phonenum ,
: min(calltime) as min_calltime
: from your_table
【在 i******7 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: 哦.我可能没有说清楚.实际上这个calltime的格式是:mm/dd/yyyy hh:mm:ss的.所以觉
: 得那个+1可能不work.如果格式包括时间,该怎么写呢?
:
: 发信人: cheungche (你不乖), 信区: Database
: 标 题: Re: 请教一下这个report的query应该怎么样写?
: 发信站: BBS 未名空间站 (Mon Oct 18 18:44:55 2010, 美东)
: 先做一个辅助table
: select phonenum ,
: min(calltime) as min_calltime
: from your_table
v*6
35 楼
元宵节快乐!
A*8
36 楼
元宵节快乐!
s*0
37 楼
排!
l*0
38 楼
排
s*s
39 楼
吃,元宵快乐!
G*5
40 楼
牌!
相关阅读
how to dump a oracle database to csv file?[转载] 求教: 转数据库服务器,装什么CPU+主板+内存?安装ORACLE8.1.7遇到问题[转载] SQL in Access[转载] A silly question about oracle9iRe: why?ORACLE的c编程中,循环语句中如果出现数据库语句,循环就会死掉Can not install oracle8.1.7 on xp pro?download version Oracle discoverer installation problemHow to get real time data from a webpage and input it into database automatically?是否有可以比较日期大小的函数?Help~~~~please. copy database tables from MSSQL server to Oracle9i DB in red hat linux7.3大家的SQL SERVER的客户端应用程序都是用什么界面a simple questionHelp: SASOracle每次一重启就不能用了...help please~Access数据库能存一二十万条记录吗?Re: 在家里的机器上用SQL server的大侠都不用win2k/xp pro 而用win2k/NT seWhy it took 4 hours to install Oracle9.2?现在都研究什么问题Oracle 8 certification