I have the following data: ID Date Total A 2021-09-03 0 A 2021-09-04 12 A 2021-09-05 37 A 2021-09-06 40 B 2021-08-03 20 B 2021-08-04 43 B 2021-08-05 75 And from this data, I would like to get the following table: ID Date Total Daily A 2021-09-03 0 0 A 2021-09-04 12 12 A 2021-09-05 37 25 A 2021-09-06 40
Tag: mysql
MYSQL Select different records from same table
I am working on small school database and I need some help with selecting students that are only booked on different days in week 1 and week 2. My table structure is like below: I would like to get all the children that meet the following criteria: ONLY booked in week two (This is ChildId 2 and I can get
How can I use IF and CONCAT within SELECT
I have this Adjacency List Model table Table: Output: So I have the following query that duplicates a Site 1 e.g. and its children. In this case, the children are Paper with parent_id = 2 and ms1 with parent_id = 3 Output: As you can see Site 1 and its children got duplicated with a new unique id. However for
How do I fix the error that occurs when I enter the file path and date in mysqldump?
How do I fix the error that occurs when I enter the file path and date in mysqldump? I ran the mysqldump command as follows in cmd: set _my_datetime=%date:-=% mysqldump -u root -p –all-databases -pMyPassword > C:Program FilesMariaDB 10.4databackup%_my_datetime%.sql But the result is: I wonder how to …
Subqueries in MySQL
My first post here and I am desperate. Need this to complete the last 2 questions of my assignment. This is the code I wrote and it is outputting almost what I need. The problem in the assignment wants to display Employees or Guests that are from Winnipeg or London. My code gives me all the cities for each em…
Converting timestamp from one column of an SQL table to dates in another column of the same table
I’d like to convert unix timestamps from one column of an existing sql table to dates in another column of the same table. Something like this: take the values of column TIMESTAMP from every raw and convert it into a date and put it into column DATE. I already figure out that the below expression conver…
Bulk insert data into empty (but existing) records with SQL
The first table columns (A to G) are already filled with data for each row/record, but the columns H to K have no data in it yet. So I have to add data for these columns, for each individual row in the table (1 to 285, whatever the number is). Columns A to G should remain unaltered! What SQL query
How I can integrate two function in the same request
I want to display the most ordered product with its name but I don’t know how to integrate the max and count function in the same request Answer here is how you can do it:
SQL – Select rows with greatest revision that are less than a set revision
I have an audit table where entities are stored by id and an associated revision number and revision type (this is a Hibernate Envers audit table). E.g. id rev revtype foo_description 10 1 0 10 foo v1 10 3 1 10 foo v2 10 4 1 10 foo v3 20 2 0 20 foo v1 20 4 1 20 foo
Cannot connect to database stored on aws from Heroku or Replit websites. (mysql2, node.js)
Problem: My discord.js bot isn’t connecting to the mysql database on aws. The bot is being hosted on replit and also on heroku but for some reason I can’t connect to both. I have tried connecting to the database from my laptop and it worked fine, I even hosted the bot on my laptop to see if there …