提供另一種解法
假設資料表名稱#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)