我是 SQL 新手,希望得到一些帮助。
这是我的表:
ID Name Number Src_Call_Leg Dest_Call_Leg
-- ---- ------ ------------ -------------
1 John 5555 100 1000
2 John 5555 100 102
Run Code Online (Sandbox Code Playgroud)
该表存储呼叫记录。当呼叫 5555 时,系统首先接受源呼叫支路 100 和目的地呼叫支路 1000 以及最终目的地呼叫支路 102,然后由 John 应答。源调用段在整个过程中没有变化。
我想要的是仅显示具有名称、号码、源呼叫支路和最终目的地呼叫支路的数据,以记录临时呼叫支路以 1000 开头的记录。
我尝试这样做,但没有用。这是我的尝试:
select
tb.name,
tb.number,
tb.Src_Call,
tb.Dest_Call_leg
from
table tb
where
tb.Src_Call_Leg IN (
select
tb1.Src_Call_Leg
from
table tb1
where
tb1.Dest_Call_Leg like '1000%'
);
Run Code Online (Sandbox Code Playgroud)
我知道我在做一些非常愚蠢的事情,如果有人能指出这一点,我将不胜感激。
subquery ×1