静的な文字列をデータセットに連結したいのですが、フェッチしたデータに文字列をmin、avg、maxとして追加したいと思います。私がいくつかのエラーを与えようとしているとき?
私の質問
select m.medTitle,
min(TIMESTAMPDIFF(SECOND, s.dmtViewStart, s.dmtViewEnd)) playtime
from tbldoctormediatracktest s
left join tblmedia m on s.dmtMedId = m.medId
group by m.medTitle
union all
select m.medTitle,
avg(TIMESTAMPDIFF(SECOND, s.dmtViewStart, s.dmtViewEnd)) playtime
from tbldoctormediatracktest s
left join tblmedia m on s.dmtMedId = m.medId
group by m.medTitle
union all
select m.medTitle,
max(TIMESTAMPDIFF(SECOND, s.dmtViewStart, s.dmtViewEnd)) playtime
from tbldoctormediatracktest s
left join tblmedia m
on s.dmtMedId = m.medId
group by m.medTitle
order by medTitle, playtime;
私が試していること。
select concat(m.medTitle,'minimum'),
min(TIMESTAMPDIFF(SECOND, s.dmtViewStart, s.dmtViewEnd)) playtime
from tbldoctormediatracktest s
left join tblmedia m
on s.MedId = m.MedId
group by m.medTitle
union all
select concat(m.medTitle,'average'),
avg(TIMESTAMPDIFF(SECOND, s.dmtViewStart, s.dmtViewEnd)) playtime
from tbldoctormediatracktest s
left join tblmedia m
on s.MedId = m.MedId
group by m.medTitle
union all
select concat(m.medTitle,'maximum'),
max(TIMESTAMPDIFF(SECOND, s.dmtViewStart, s.dmtViewEnd)) playtime
from tbldoctormediatracktest s
left join tblmedia m
on s.MedId = m.MedId
group by m.medTitle
order by medTitle, playtime