select template_id, text
from questionary_eventlog qe
where template_id in (26, 217)
group by template_id
limit 2
我擁有的
| 模板編號 | 文本 |
|---|---|
| 26 | 你有一個bonuce/azmm/eee |
| 26 | 你有一個bonuce/azmm/fff |
我需要的
| 模板編號 | 文本 |
|---|---|
| 26 | 你有一個bonuce/azmm/eee |
| 217 | 你是贏家/azmm/fff |
我試過的
select template_id, text
from questionary_eventlog qe
where template_id in (26, 217)
and
text = (select distinct left(text,17) from questionary_eventlog
group by template_id
limit 2
uj5u.com熱心網友回復:
您可能希望通過聚合獲得正確的組
select template_id, max(text) text
from questionary_eventlog qe
where template_id in (26, 217)
group by template_id
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/451183.html
標籤:sql PostgreSQL
上一篇:如何從字串中提取日期
