Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Get the value based on row before
drop table if exists t; create table t (A int,B int); insert into t values ( 1 , 300 ), ( 2 , 300 ), ( 3 , 0 ), ( 4 , 0 ), ( 5 , 100 ), ( 6 , 100 ), ( 7 , 100 ), ( 8 , 100 ), ( 9 , 0 ), ( 10 , 0 ), ( 11 , 0 ), ( 12 , 0 ), ( 13 , 100 ), ( 14 , 100 ), ( 15 , 100 ), ( 16 , 0 ); set @val := 100; set @pre := -999999999; select a, b from ( select t.*, if(@val = b and @pre = 0, if(@pre := b, 1, 1), if(@pre := b, 0, 0)) flag from t order by A ) t where flag = 1;
run
|
edit
|
history
|
help
0
Lanaldiak
bdUrbanFix
test
Get second least column in a row in mysql
Question no:2
Legitimate Resale
sree..
Show databases;
air_flight
rutujafulari