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

Analysis function rewrites not in

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

Share

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

1.OLD:

SELECT card.c_cust_id, card.TYPE, card.n_all_money FROM card WHERE card.c_cust_id NOT IN (SELECT c_cust_id FROM card WHERE TYPE IN ('11','12') '13,' 14') AND flag ='1') AND card.TYPE IN ('11,'12') '1300,' 14') AND card.flag ='F'

two。 Optimization direction

(1)。 The main query uses the same table as the subquery, and the conditions are similar. Consider merging.

(2)。

Use the parse function to find the same c_cust_id: card.flag ='F' and flag ='1' or just satisfy flag ='1' and filter out this part of the record.

When the grouping result card.flag ='F' also flag ='1' min (flag) over (partition by card.c_cust_id) ='1'

When the grouping result flag ='1' min (flag) over (partition by card.c_cust_id) ='1'

When the grouping result flag ='F' min (flag) over (partition by card.c_cust_id) ='F' (required)

Select card.c_cust_id, card.TYPE, card.n_all_moneyfrom (select card.c_cust_id, card.TYPE, card.n_all_money, min (flag) over (partition by card.c_cust_id) from card where card.TYPE IN ('11','12' '1300,' 14') and card.flag in ('1pm, F')) where card.flag =' F'

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