select group_concat(if(v='a', c, null)) a,
group_concat(if(v='b', c, null)) b,
group_concat(if(v='c', c, null)) c
from (select value v, Count(value) c
from t1
group by value ) temp
SELECT * FROM (
SELECT * FROM User
WHERE id IS NULL) t2
WHERE t2.name = 'google'
SELECT *
FROM User
WHERE User.id IS NULL AND User.name = 'google'
SELECT Max(max_fast_jackpot, max_coinflip_jackpot)
FROM (
SELECT *,
(SELECT Coalesce(Max(won_amount), 0)
FROM `fast_games`
INNER JOIN `fast_bets` AS `winning_fast_bets`
ON `winning_fast_bets`.`id` =
`fast_games`.`winning_bet_id`
WHERE users.id = winning_fast_bets.user_id
AND `fast_games`.`state` = ?)
AS `max_fast_jackpot`,
(SELECT Coalesce(Max(won_amount), 0)
FROM `coinflip_games`
INNER JOIN `coinflip_bets` AS `winning_coinflip_bets`
ON `winning_coinflip_bets`.`id` =
`coinflip_games`.`winning_bet_id`
WHERE users.id = winning_coinflip_bets.user_id
AND `coinflip_games`.`state` = ?)
AS `max_coinflip_jackpot` )
FROM `users`
WHERE `id` = ?
)
SELECT * FROM
(
select
ID
, LEAD(id) OVER (ORDER BY user_id) lead_id
from your_table
) tab
WHERE tab.id= tab.lead_id
SET DEFINE "&"
VAR db_name VARCHAR2(30)
COLUMN db_name NEW_VALUE db_name
EXEC :db_name := 'Blah';
SELECT :db_name AS db_name FROM dual;
DEFINE db_name
SELECT
t2.datetime
, param2
, (SELECT param1
FROM
(SELECT
t1.param1
, row_number() OVER(ORDER BY t1.datetime DESC) rankparam1
FROM table1 t1
WHERE t2.datetime>=t1.datetime)
WHERE rankparam1 = 1)
as param1
FROM table2 t2