你可以起诉很多情况下
select agent,
case day when 'Mon' then start end as start_mon,
case day when 'Mon' then `end` end as end_mon,
case day when 'Tue' then start end as start_tue,
case day when 'Tue' then `end` end as end_the,
case day when 'Wed' then start end as start_wed,
case day when 'Wed' then `end` end as end_wed
from your_table
对于刚开在同一行代理的价值,你可以使用一个临时表和组BT
select agent, max(start_mon), max(end_mon), max(start_tue), max(end_tue), max(start_wed), max(end_web)
from (
select agent,
case day when 'Mon' then start end as start_mon,
case day when 'Mon' then `end` end as end_mon,
case day when 'Tue' then start end as start_tue,
case day when 'Tue' then `end` end as end_the,
case day when 'Wed' then start end as start_wed,
case day when 'Wed' then `end` end as end_wed
from your_table) as t
group by agent;
您只需要1个查询就可以了。到目前为止,你有什么? – jeroen
我每天都想做这样的事情: 选择(从日程安排中选择start_dt,其中day ='Mon')为'MonStart', (从日程安排中选择end_dt ='Mon')为'EndStart'; –
如果会有更多的代理商,“agent2”,“agent3”,该怎么办? – RomanPerekhrest