用于组合行的复杂 SQL 查询
我首先有 2 个表,还有
Thread { code, itr_global,campaign, contact, start_time,duration}
segment {code,thread,start_time,duration,state}
多个其他连接,但这两个是主要连接。 2个表的关系为thread.code=segment.thread。
在段表中,单线程将有多行。我需要获取值
活动开始时间持续时间waititme talk_timehold_timewrap_time
其中wait_time我可以得到segment.state=7& talke_time=segment.state=6 &换行时间为segment.state=8 我无法在单行中获取所有这些值,因为它将为每条记录提供 3 个不同的行。如何按照上述格式获取单行中的所有值。
I have 2 tables first is
Thread { code, itr_global,campaign, contact, start_time,duration}
segment {code,thread,start_time,duration,state}
There are multiple other joins but these 2 are major joins. 2 table are realted as thread.code=segment.thread.
In segment table there will be multiple rows for singl thread. I need to get values
campaign start_time duration waititme talk_time hold_time wrap_time
Where wait_time I can get as segment.state=7 & talke_time=segment.state=6 & wrap time as segment.state=8
I am not able to get all these values in single row as it will give me 3 diffrent rows for each record. How can I get all the values in single row as per above format.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要一些条件聚合
SUM(CASE...)
才能获得您想要的结果。所有这些都是基于我对表格结构和含义的猜测,您从问题中省略了这些猜测。
You need some conditional aggregation
SUM(CASE...)
to get the result you want.All this is based on my guesses about the structure and meaning of your tables, which you omitted from your question.