select user_id
from t
where value_id = 22
group by user_id
having count(*) = 1
intersect
select user_id
from t
where value_id = 23
group by user_id
having count(*) = 2
with count_values as (
select user_id, value_id, count(*) cnt
from t
group by user_id, value_id
)
select user_id from count_values where value_id = 22 and cnt > 0
intersect
select user_id from count_values where value_id = 23 and cnt > 1
селект *
фром тбл
вэа юзер_ид ин(
селект юзер_ид
фром тбл
вэа валуе_ид = 23
груп бай валуе_ид
хэвинг каунт(*) = 2
) т1
энд валуе_ид = 22
select
date(`datetime`),
sum(case when `action_type` = 'value_add' then `value` else -`value` end) `total`
from t
group by date(`datetime`)
export const copy = (str: string) => {
try {
navigator.clipboard.writeText(str);
} catch (err) {
const textArea = document.createElement("textarea");
textArea.value = str;
textArea.style.setProperty("width", "0");
textArea.style.setProperty("height", "0");
textArea.style.setProperty("position", "absolute");
textArea.style.setProperty("left", "-99999px");
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
document.execCommand("copy");
} catch (err) {
// eslint-disable-next-line no-console
console.error(err);
}
document.body.removeChild(textArea);
}
};
SELECT query, COUNT(*) cont FROM (
SELECT
CASE
WHEN val LIKE '%111%' THEN '%111%'
WHEN val LIKE '%222%' THEN '%222%'
ELSE 'other'
END query
FROM tbl
WHERE val LIKE '%111%' OR val LIKE '%222%'
) tbl GROUP BY query;
+=======+======+
| query | cont |
+=======+======+
| %111% | 2 |
+-------+------+
| %222% | 1 |
+-------+------+