Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Get the value based on row before
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
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;
absolute service time: 0,36 sec
edit mode
|
history
|
discussion