Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How MySQL generally implements the sql writing method of phase accumulation (with a code example)

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The following content mainly brings you MySQL is generally how to achieve stage accumulation of sql writing (to code examples), the knowledge mentioned, slightly different from books, are summed up by professional and technical personnel in the process of contact with users, with a certain experience sharing value, hoping to bring help to the majority of readers.

Recently, there is a demand: count the balance after daily recharge / consumption, which is actually very simple, just calculate the balance after each recharge / consumption, and then save it. But for this kind of requirement, one sql can do it, and there is no need to do redundant fields.

The chart shows that this scene may be more straightforward.

The desired result

Write method 1:

Select T. price, (select sum (price) from t_charge temp where temp.date)

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report