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

T-SQL advanced query statement

2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

System functions:

String function:

The basic salary of select 'operation and maintenance engineer' + name +'is:'+ CAST (basic salary as varchar (10)) + 'yuan' from A1where job = 'operation and maintenance engineer' # display the names and basic salary of all operation and maintenance engineers in table A1. The required display format is that the basic salary of operation and maintenance engineer so-and-so is 9000.00 yuan.

Date function:

Select DATEADD (dd,10,GETDATE ()) # displays the date and time after the current 10 days select name, DATEDIFF (YY, date of birth, GETDATE ()) AS age from Aids displays the names and ages of everyone in A1 table select name, DATENAME (YY, date of birth) AS year of birth from A1where birth date between '1990-1-1' and '1999-12-31 birthday # shows the names and years of birth of all post-90s employees in A1 table

Aggregate function:

Select SUM (basic wage) AS Total wage from A1 # query the sum of the basic wages of all employees in table A1 select AVG (basic wage) AS average wage from A1 # query the average basic wage of all employees in table A1 select MAX (basic wage) AS maximum wage MIN (base wage) AS minimum wage from salary query A1 table the highest and lowest base wage select COUNT (*) AS total rows from Aids query A1 table total rows select COUNT (date of birth) AS'90 number of people 'from A1where date of birth > =' 1990-1-1 employee number of post-90s employees in A1 table

Group query:

Select job, AVG (base salary) AS job average salary from A1 group by job # query the average salary of each job in table A1 select job, AVG (base salary) AS job average salary from A1 group by job having AVG (base salary)

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