Home > database >  Update and group by how to use
Update and group by how to use

Time:09-30

Such as have the query:
SELECT the purchase date, title, the sum total number (quantity) as
FROM the table name
GROUP BY purchase date, the title

The above query to update statement, how to change with the update and group by
Mean I hope I can be grouped to update

CodePudding user response:

What do you want to update

CodePudding user response:

I am the building Lord, demand is changed to the following:
If the title is the name, the time a datetime, number of num
There is A number called the title A, every library in the different periods, the number of requirements on the day of every library to A together, and then merged into the day only A A record (note that on the day of the storage A record might have been)

CodePudding user response:

Are merged into A record, because want to statistics on the day of the title of A total number

CodePudding user response:

The subquery can (reference code, without debugging) :
 
The UPDATE t1 JOIN (
SELECT buyDate, bookId, COUNT (1) bookCount
The FROM t2
GROUP BY buyDate, bookId
T3) ON t1. BuyDate=t3. BuyDate AND t1, bookId=t3. BookId
The SET t1. BookCount=t1. BookCount + t3. BookCount
-- the WHERE...


  • Related