'I can't select unique text from template_id
select template_id, text
from questionary_eventlog qe
where template_id in (26, 217)
group by template_id
limit 2
What I have
| template_id | text |
|---|---|
| 26 | you have a bonuce/azmm/eee |
| 26 | you have a bonuce/azmm/fff |
What I need
| template_id | text |
|---|---|
| 26 | you have a bonuce/azmm/eee |
| 217 | you are winner /azmm/fff |
What i tried
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
Solution 1:[1]
You may want a correct group by aggregation
select template_id, max(text) text
from questionary_eventlog qe
where template_id in (26, 217)
group by template_id
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Serg |
