Skip to content

Query Last data group by column

I have this data; date owner p.code product —- —– —– —— 21.08.2020 Micheal 5 apple 22.08.2020 Micheal 5 apple 15.08.2020 George 4 biscuit 14.08.2020 …

MariaDB Pivot Table Performace

I have a table containing data with dynamic categories: +———-+————–+—————+———+ | category | string_value | integer_value | user_id | +———-+————–+———…

MySQL: Select newest two rows per Group

I have a table like this: CREATE TABLE `data` ( `id` int(11) NOT NULL, `deviceId` int(11) NOT NULL, `position_x` int(11) NOT NULL, `position_y` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=…

How to create a leaderboard as a database

I need to create a database which is a top 5 leaderboard, however, what I tried didn’t work – it brought up many different errors (code below): Problems: The 4th line beginning “db = ” comes up with an error on the brackets. I initially thought it had to do with the fact that I am tryi…

How do I count and sum from different tables (SQL)

I am trying to write an SQL statement that does this: For each customer that has an order, I need to list the customer’s number, the number of orders that customer has, the total quantity of items on those orders and the total price for those items. I then to need sort the result by the customer number.…