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

The method of sql multi-table row-to-column and cascading row-to-column

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "the method of sql multi-table row transfer and cascade row transfer". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn the "sql multi-table row transfer and cascading row transfer method"!

There are two tables A, A, B, A, B, A, A, B, B, A, B, A, B, B, A, B, Table B is required to display a list of clicks on all items of the day with the following code: declare @ sql varchar (2000) set @ sql='select CONVERT (varchar, a. [Time], 23) as time, total count (b.title) as' select @ sql= @ sql+' Sum (case b.title when''+ Title+''' then 1 else 0 end) as'+ ['+ Title+'] 'from (select distinct title from B) as B set @ sql=@sql+' from An as a left join B as b on a.AId=B.Aid group by CONVERT (varchar, a. [Time], 23) order by CONVERT (varchar (100), a. [Time], 23) desc' exec (@ sql)

Display result time Total Commodity 1 Commodity 2 Commodity 32013-11-1151042013-11-10132111

At this point, I believe that everyone on the "sql multi-table row transfer and cascade row transfer method" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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