_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › 覯譴覲給語

Contents

1 覓語
2 願屋


覯 覓語螳 蠏狩 螻襴覃伎 譯 讌覓語 蟆企. 螻覲企 螳訖 朱..

1 覓語 #


螳 一危 .

A intime outtime
1 10:00 12:00 *
1 11:00 14:00 *
1 15:00 16:00
2 13:00 15:00 *
2 12:00 14:00 *
3 08:00 11:00

れ螻 螳 覯螳 譴覲給 蟇伎 覈 蟇伎語 螻 矩.

A count
1 2
2 2
3 0

2 願屋 #

るジ 覦覯 讌襷, 所 讌覲伎螳 危 貎朱Μ螳 譬 貎朱Μ~

;with temp (a, intime, outtime)
as
(
	select 1, 10, 12 union all
	select 1, 11, 14 union all
	select 1, 15, 16 union all
	select 2, 13, 15 union all
	select 2, 12, 14 union all
	select 3, 08, 11
)
select 
	a.a
,	count(case when b.a is not null then 1 end) cnt
from temp a
	left join temp b
		on a.intime <= b.outtime
		and a.outtime >= b.intime
		and a.a = b.a
		and a.intime <> b.intime
		and a.outtime <> b.outtime
group by
	a.a	
/*
 螳 覯螳 る..
   |------------|
      *----------------> 
<-------------* 譬襭

企蟆 れ伎る true .

   |------------|
                *----------------> 
         <-------------* 譬襭
企蟆 覃 譬襭譟郁唄 true企  false企襦 2螳 譟郁唄 and覃 false螳 .

*/
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:52

轟 蟆 伎 覓語 伎企. (蠏碁殊)