In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
In this issue, the editor will bring you about how to use query sentences in SQL Server. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
one。 The copy code for querying all the information of the employee whose second letter is t or an is as follows: select * from employeeswhere firstname like'_ [tpene a]%'
Note:% represents a string in sql, so you can't annotate it like matlab. Even two double slashes don't seem to work. / * / you can. Some netizens say that sql's one-line comment is--
two。 The copy code for changing the field name is as follows: select 'first name' = firstname, 'Last name' = lastnamefrom employees where firstname like'_ [tmena]%'
Or the copy code is as follows: select firstname as' first name', lastname as' last name 'from employees where firstname like' _ [t _ a]%'
3. The copy code for the top keyword is as follows: / * retrieve the first 70% records that meet the criteria * / select top 70 percent firstname as' first name', lastname as' last name 'from employees where firstname like _ [tforce a]%' 1 / * retrieve the first 2 records that meet the criteria * / select top 2 firstname as' first name', lastname as' last name'_ [tmema]%'
IV. Union keyword Note: standard sql only provides intersection and minus operations, not intersection and difference operations. The copy code is as follows: select * from employeeswhere title = 'Sales Manager'union select * from employeeswhere address is not null
Display:
Server: message 8163, level 16, status 4, line 1 cannot select text, ntext, or image data types as DISTINCT. The copy code is as follows: select * from employeeswhere title = 'Sales Manager'union allselect * from employeeswhere address is not null
Query analysis of the analysis query (check mark) is to see if there are syntax errors (ctrl + F5), the execution of the query (right triangle) (F5) is to display the results, if there are syntax errors, do not execute.
5. Compute keyword
The compute clause requires the following information: the optional By keyword calculates the specified row aggregate function on a column: the column on which sum,avg,min,max,count executes the row aggregate function when compute has an optional By clause, each group that meets the select condition has two result sets: the first result set of each group is a detail rowset, which contains the group's selection list information. The second result set of each group has one row. The summary copy code containing the aggregate functions specified in the set of COMPUTE clauses is as follows: select sex,sclass,score from student order by sex compute sum (score) by sex
Note: order by is required, and the parameters after compute by should have been copied in the parameters after order by. The code is as follows: select sex,sclass,score from student compute sum (score)
This is how to use query statements in SQL Server shared by Xiaobian. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to 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.