Select Max Count of consecutive rows with same value mariaDB mysql - mariadb

I got a table like this, and i want to get the largest consecutive count of rows where win=1 for each puuid and ordered by game_creation DESC. I tried many solution of the web but can't get any of them to work, maybe somebody here can help me.

Related

SQLITE increase Maximum number of Columns

I've got a table with too many columns in QGIS software so I would like to increase the maximum column limit in SQLite. The limit is set to 2000 columns and I would like to increase it.
The exact same issue as shown here :
SQLITE3 increase Max Columns
The problem is that I'm quite a beginner and I'm missing some steps to start from step 3 and 4. I'm completely lost here.
Could someone give me a hand?

How to count the number of rows in a crossTab in Cognos

Simply put, i have this crossTab with rows and columns and manually created measure. Everything seems to work fine.
I now simply need to count the numbers of rows it displays for each ROW values.
ROWS from left to right: ItemCountry, Manager
Columns from left to right: Choice#1, Choice#2, Choice#3
Measure:QTY for each [Choice#1], [Choice#2], [Cjoice#3]
I now need: Nb of rows for by ItemCountry, Manager
I now need: sum of [Choice#1], [Choice#2],[Choice#3] by ItemCountry and by Manager
Thanks!
You don't indicate if you've tried count distinct and found it wanting.
I'm at a bit of a handicap as your last two paragraphs are not necessarily as clearly stated as one might hope, unfortunately. In particular, but not exclusively, it's not clear what Choice#3, Choice#2, and Choice#1 are.

How to find the nth largest value of each row in SQL

I have researched this problem and have found the answer for a single query, where you can find the nth value of a single column by using DESC OFFSET 2. What I am trying to do is find the nth value for each item in a row. For example, I'm working with a data base concerning bike share data. The data base stores the duration of each trip and the date. I'm trying to find the 3rd longest duration for each day in a data base. If I was going to find the max duration I would use the following code.
SELECT DATE(start_date) trip_date, MAX(duration)
FROM trips
GROUP BY 1
I want the output to be something like this.
Date 3rd_duration
1/1/2017 334
1/2/2017 587
etc
If the value of the third longest duration is the same for two or more different trips, I would like the trip with the lowest trip_id to be ranked 3rd.
I'm working in SQLite.
Any help would be appreciated.
Neither SQLite nor MySQL have a ROW_NUMBER function built in, so get ready for an ugly query. We can still group by the date, but to find the max duration we can use a correlated subquery.
SELECT
DATE(t1.start_date) AS start_date,
t1.duration
FROM trips t1
WHERE
(SELECT COUNT(*) FROM trips t2
WHERE DATE(t2.start_date) = DATE(t1.start_date) AND
t2.duration <= t1.duration) = 3;
Note that this approach might break down if you could have, for a given date, more than one record with the same duration. In this case, you might get multiple results, neither of which might actually be the third highest duration. In order to handle such ties, you should tell us what the logic is with regard to ties.
Demo here:
Rextester

Average result of last 10 rows

I'm trying to find the average figure for the last 10 rows in a database table:
select avg(Reading)
from Readings
Order By Rowid
desc limit 10;
This pulls the average of all entries in the table, not the last 10. I've tried all sorts of variations but can't get it to work.
Thanks for the super quick replies, I tried again and managed to type in the correct syntax this time in the From clause.
Here is the correct answer:
select avg(Reading)
from(select Reading
from Readings
Order By Rowid desc
limit 10);

Selecting rows in sqlite based on date

I have a table of which one column holds dates in this format '04/17/2014'.
I want to select rows of the table based on time. I'm trying to get all rows after a certain date. After reading posts here I tried the following, which doesn't seem to work. I get a lot of rows from 2013 back with this query. Can anybody help?
select Value_Date from Table_Outstanding
where VALUE_DATE > '04/12/2014'
This did it. Thanks everybody.
select * from Table_Outstanding
where strftime('%m/%d/%Y', VALUE_DATE) > '04/12/2014'

Resources