In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Summary:
The following describes how to subtract two adjacent pieces of data using a sql script, as follows:
Lab environment: sql server 2008 R2
The idea of realization is:
1. Renumber the current table using cte expressions
two。 Use the left join to misplace the temporary table generated by the expression and subtract the two columns in the new record
Create table [maomao365] (sort varchar (30), qty int) Go---- generates basic data insert into [maomao365] (sort, qty) values ('maomaoA',10), (' maomaoB',20), ('maomaoC',30), (' maomaoD',40), ('maomaoE',50), (' maomaoF',60) gowith cte_temp as (select row_number () over (order by qty asc) as keyId, * from [maomao365]) select a.sortjora.qtyjol b.qty, (isnull (a.qtyline 0)-isnull (b.qty) 0) as [difference between adjacent rows] from cte_temp aleft join cte_temp b on a.keyId = (b.keyId+1)-calculate the difference between two adjacent rows gotruncate table [maomao365] drop table [maomao365]
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.