there are 2 tables in Mysql 1. inbox tables Inbox table

  1. Outbox table Outbox table

As you already understood, inboxe stores the arrival operations and, in the outboxe, the money outflow operations. In the inbox table, the inbox_date field is responsible for the arrival date and inbox_sum for the receipt amount. Also in the outbox table in the outbox_date field the expense date is stored and the outbox_sum field stores the amount of the expense. (The remaining fields have no value for this question) Attention question: What kind of query should be done to display the data in the HTML table in this form: enter image description here Tell me at least which way to dig and which command to use. I'm new to MYSQL. PS about the construction of HTML tables do not have to answer just need the right query from the database

  • one
    You can group the arrival table by date (group by), wrap it in an external query and join the consumption by date. you receive at the output a sample in each row of which is the total amount of income on the date and of a particular single expense. And then it's up to design - Mike
  • you can try this: SELECT i.inbox_date AS 'Number', SUM (i.inbox_sum) OVER (PARTITION BY i.inbox_date) AS 'Coming', (SELECT o.outbox_sum FROM outbox AS o WHERE o.outbox_date = (SELECT inbox_date FROM inbox)) AS 'Consumption', ((SELECT SUM (p.inbox_sum) OVER (PARTITION BY p.inbox_date) FROM inbox AS p) - (SELECT SUM (r.outbox_sum) OVER (PARTITION BY r.outbox_date) FROM outbox AS r)) AS 'Balance' FROM inbox AS i; - Yaroslav
  • Yaroslav, I would like to pull out all the information from the database at a time and not by the number ... only with grouping by numbers) And so I got 23 errors - Taisiya Lerkova
  • Mike, could you explain the phrase "wrap in an external query"?) - Taisiya Lerkova
  • @ Taisiya Lerkova, complete the question with scripts of tablets and test data! - Yaroslav

0