作者decadance (世界尽头小酒馆)
看板Database
标题Re: [SQL ] select 资料表中每月月初及月底的资料( …
时间Sat Nov 22 04:19:07 2008
提供另一种解法
假设资料表名称#test,日期tDate,交易tTotal
select tDate,tTotal from #test
where tDate in
(
select max(tDate) as tDate from
(
select tDate, SUBSTRING(tDate,0,6) as tYYYMM from #test
) temp
group by tYYYMM
union
select min(tDate) as tDate from
(
select tDate, SUBSTRING(tDate,0,6) as tYYYMM from #test
) temp
group by tYYYMM
)
--
现在是半夜四点...明天还要去加班
还在这边回文... orz 我一定得了[解程式强迫症]
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.224.44.230
※ 编辑: decadance 来自: 61.224.44.230 (11/22 04:41)