Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
How to run query to keep maximum 3 rows with the same name
drop table if exists ss_remote_inventories; CREATE TABLE ss_remote_inventories (`id` int, `item_name` varchar(5), `price_good` int) ; INSERT INTO ss_remote_inventories (`id`, `item_name`, `price_good`) VALUES (1, 'Row 1', 1), (2, 'Row 1', 1), (3, 'Row 1', 0), (4, 'Row 1', 0), (5, 'Row 1', 1), (6, 'Row 1', 1), (7, 'Row 1', 1), (8, 'Row 1', 1), (9, 'Row 2', 0), (10, 'Row 2', 1) ; update ss_remote_inventories t set t.price_good = 0 where id in ( select id from( select a.* from ss_remote_inventories a where a.price_good = 1 and ( select count(*) from ss_remote_inventories b where a.item_name = b.item_name and b.price_good = 1 and a.id > b.id ) > 2 ) t1 ); select * from ss_remote_inventories
run
|
edit
|
history
|
help
0
Get the value based on row before
cus
filter the growth rate for current month
MySQL : calculate overlapping periods
Wenfeng Ou
daily score
akshay dbms query
gandu
test
My name is busy