In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article is about how to achieve the maximum value of multiple fields according to the range in MSSQL, the editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it with the editor.
-- > Title: generate test data-- > Author:wufeng4552-- > Date: 2009-09-21 15:08:41declare @ T table ([Col1] int, [Col2] int, [Col3] int, [Col4] int, [Col5] int, [Col6] int, [Col7] int) Insert @ Tselect 1020,0,30,40,50,50,60,50,0,52,85 union allselect 385 union allselect 387, 56pr 41pm21 1select [col1], max ([col2]) maxcolfrom (select [col1], [col2] from @ t union allselect [col1], [col3] from @ from] [col4] from @ t union all select [col1], [col5] from @ t union all select [col1], [col6] from @ t union all select [col1], [col7] from @ t) Twhere [col2] between 20 and 60-conditional restrictions group by [col1] / * col1 maxcol--1 602 603 56
(3 data columns are affected)
* /-- method 2select [col1], (select max ([col2]) from (select [col2] union all select [col3] union all select [col4] union all select [col5] union all select [col6] union all select [col7]) T where [col2] between 20 and 60) as maxcol--specify query range from @ tUnip * (3 data columns are affected) col1 maxcol--1 602 603 56 /
The above is how to achieve the maximum value of multiple fields according to the range in MSSQL. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
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.