I’m doing a leetcode question. 2 similar answers are worked out. But I have no idea why one is wrong and the other is right. The following is the question link. The goal is writing a SQL query to find all numbers that appear at least three times consecutively. https://leetcode.com/problems/consecutive-numbers/ The table looks like Right version: The output: Wrong version:
Tag: mysql
Mysql unknown column in subquery works
There are three tables – mapping_hospital_procedure, master_hospital and master_procedure. master_hospital contains an id column to identify each hospital. master_procedure also contains an id …
How to find the distance traveled by user in a particular year?
UserId, SRC, DST, Mode, Dist, Year 1,CHN,IND,airplane,200,1990 2,IND,CHN,airplane,200,1991 3,IND,CHN,airplane,200,1992 4,RUS,IND,airplane,200,1990 5,CHN,RUS,airplane,200,1992 6,AUS,PAK,airplane,200,…
UPDATE statement using the same table in subquery
SELECT vl1.phone_number, vl1.first_name, CONCAT( SUBSTRING( ( SELECT vl2.phone_number FROM list as vl2 …
return the rows by family with sql
This is my first question in stackoverflow so be nice to me 🙂 i have a table which has a column family, when i make a query (with a where statment) i want to show the results as a group of rows with …
Error 1064 when using SQL with INSERT INTO … SELECT … ON DUPLICATE KEY UPDATE
I am trying to use ‘INSERT INTO … SELECT ON DUPLICATE KEY UPDATE feature’ but I’m in trouble now. I want to insert data to ‘fruitProperty’ table. My query is as below: START TRANSACTION; SET @…
Count of past instances in an appended table
This is my desired output: ‘CountOfUsersBought’ I want it to be Amongst All Targeted Users. And the Table (Updated Daily) from where I get the data to fill the previous output has the following structure: I want to store on the variable ‘CountOfUsersBought’ the count of all the users that actually bought, not only today but all time. How would
Mysql : can’t figure out what’s wrong with this LEFT JOIN query
I would like to do a left join on the same table (licence) that only gives me licences that have no entry in the joined table. But I can’t get any result 🙁 Here is the query (quite simple actually) …
how to get the balance of each participant from transfer table using one select query?
I have a transfer table which looks like this: transfer I would like to get the balance of each participant from the transfer table. The output of the query should looks like this: output
How obtain a list of posts by category?
I have a MySQL table that associates articles with categories. Table “posts_categories”: postId – catId 178 4 177 4 176 4 175 4 174 4 171 4 170 4 169 4 168 4 167 4 166 4 165 4 164 4 163 4 …