(....前面恕刪)
小弟沒事情做,用MS-SQL寫了一下,如果大大您不是使用MS-SQL的話你可能要改一下
語法才可以用喔︿︿
create table #test (日期 char(8),交易 int)
insert into #test values('20080130',20)
insert into #test values('20080105',100)
insert into #test values('20080103',5)
insert into #test values('20021031',45)
insert into #test values('20021008',32)
insert into #test values('20021001',86)
insert into #test values('20020203',30)
insert into #test values('20020201',65)
go
select *
from #test t1
where substring(日期,7,8) =
(
select max(substring(日期,7,8))
from #test t2
where substring(t1.日期,5,2)=substring(t2.日期,5,2)
)
or substring(日期,7,8) =
(
select min(substring(日期,7,8))
from #test t2
where substring(t1.日期,5,2)=substring(t2.日期,5,2)
)
go
drop table #test
另外....
您不是要收尋月初和月底的資料嗎?
20080130 20
20080103 5
20021031 45
20021008 32 <------10月的月初資料大大您給的好像是20021001
所以應該不是10月八號才對
20020203 30
20020201 65
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.127.194.122