Get the App
SLTechnology News&Howtos  ›  Database  › 

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

Shulou Source: shulou.com Published: 2022-05-31 18:07:40 10月04日 Update

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!

Tags: Goods methods interbank total a. code content time storage learning practicality deeper interest practicality practical simple operation log more friends results Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Huawei Apple macOS Linux