In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Order:sn
Procedures:sn,status
1. There are order table and flow table.
The order table contains the details of the order [assuming there is no order status], and each order has a variety of states: paid, in process, pending receipt, and so on. The current demand may be to query the order status of all orders that are waiting to be received.
[answer] first find all the orders whose latest status is to be received, then make a left join with the order form, and you can get it.
First, look for all orders whose latest status is waiting to be received.
Originally patted the head to think that group by order by took the first one, and then tried it, and found that what group by got back is not the latest status, but the first one after the grouping. This is because the execution order of statements in MySQL is to execute group by first and then order by. Obviously, it's impossible to get the latest one. We can find out the latest status of each order in this way.
Select sn,max (status) from procedures group by sn.
The correct thing is to write it in the following way: do a join with yourself, and finally with order join.
SELECT a.id, a.sn, a.createdpaper.type FROM (SELECT sn, max (created_at) created_at FROM procedures GROUP BY sn) b JOIN procedures an ON a.sn = b.sn AND a.created_at = b.created_at where a.type=11
Select c. Writing journal tmp.type from complaints as c right join (
SELECT a.id, a.sn, a.createdpaper.type FROM (SELECT sn, max (created_at) created_at FROM procedures GROUP BY sn) b JOIN procedures an ON a.sn = b.sn AND a.created_at = b.created_at where a.type=11
) as tmp on tmp.sn=c.sn
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.