+ -
当前位置:首页 → 问答吧 → 虚心请教上期月怎么查询?

虚心请教上期月怎么查询?

时间:2011-11-05

来源:互联网

SQL code
select t.Month_id,s.csdn,sum(s.a)
from 
month t , cost s
where
s.month_id = t.month_id
AND t.Month_id >= SUBSTR('20110701',1,6)
AND t.Month_id <= SUBSTR('20110731',1,6)
group by 
t.Month_id,s.csdn


怎么查询出 201106年的数据来。。。。。。


AND t.Month_id >= SUBSTR('20110701',1,6)
AND t.Month_id <= SUBSTR('20110731',1,6)

这个是时间是手工改变的

作者: hyt1992214   发布时间: 2011-11-05

SQL code
where t.Month_id='201106'

就行了吧.

作者: qianjin036a   发布时间: 2011-11-05

Decalre @MM Char(6)
Set @MM = '201106'

select t.Month_id,s.csdn,sum(s.a)
from 
month t , cost s
where
s.month_id = t.month_id
AND t.Month_id = @MM 
group by 
t.Month_id,s.csdn


作者: Lyongt   发布时间: 2011-11-05

SUBSTR--Oracle?

作者: roy_88   发布时间: 2011-11-05

to_char(Month_id, 'yyyy/mm ')=‘201106’

作者: roy_88   发布时间: 2011-11-05

是日期可用
add_months(date,int) 返回一个date型

作者: roy_88   发布时间: 2011-11-05