SQL RADIANS函数
结构化查询语言(SQL)中的RADIANS数值函数返回指定度数的弧度值。
RADIANS函数的语法
语法1: 此语法使用SQL表的列名与RADIANS函数一起使用:
SELECT RADIANS(Numeric_Column_Name) AS Alias_Name FROM Table_Name;
在这个第一个语法中,我们必须指定要对其执行RADIANS函数以将度数值转换为弧度的列的名称。
语法2: 这个语法使用RADIANS函数和数字:
SELECT RADIANS(Number);
RADIANS函数示例
示例1: 此示例返回指定数字(度数)的弧度值:
SELECT RADIANS(360) AS Radiansvalue_of_360;
输出:
Radiansvalue_of_360
---
6.283
示例2: 此示例返回指定数字的弧度值:
SELECT RADIANS(180) AS Radiansvalue_of_180;
输出:
Radiansvalue_of_180
---
3.14159
示例3: 该示例返回90度的弧度值:
SELECT RADIANS(90) AS Radiansvalue_of_90;
输出:
Radiansvalue_of_90
---
1.57
示例 4: 这个示例返回-45度的弧度值:
SELECT RADIANS(-45) AS Radiansvalue_of_-45;
输出:
Radiansvalue_of_-45
---
-0.785
示例 5: 这个示例返回给定表达式的弧度值:
SELECT RADIANS(180 / 3) AS Radiansvalue_of_Expression;
输出:
Radiansvalue_of_Expression
---
1.047
示例 6: 这个示例使用 SQL 表中的 RADIANS 函数。 在这个示例中,我们将创建一个新表,在该表上执行 RADIANS 函数: 以下是在 SQL 中创建新表的语法:
CREATE TABLE Name_of_New_Table
(
First_Column_of_table Data Type (character_size of First Column),
Second_Column_of_table Data Type (character_size of the Second column ),
Third_Column_of_table Data Type (character_size of the Third column),
.......,
Last_Column_of_table Data Type (character_size of the Last column)
);
下面的CREATE语句创建了Vehicle_Details表,用于存储购买和销售车辆的详细信息:
CREATE TABLE Vehicle_Details
(
Vehicle_ID INT NOT 80,
Vehicle_Name Varchar(50),
Vehicle_Quantity INT,
Purchasing_Vehicles INT,
Selling_Vehicles INT,
Release_Date Date,
Vehicle_Rating INT
);
以下是多个INSERT查询,将车辆的记录以及其数量、销售和购买车辆的数量插入Vehicle_Details表中:
INSERT INTO Vehicle_Details (Vehicle_ID, Vehicle_Name, Vehicle_ Quantity Purchasing_Vehicles, Selling_Vehicles, Release_Date, Vehicle_Rating) VALUES (140, P1, 290, 45, 80, 2022-04-30, 80);
INSERT INTO Vehicle_Details (Vehicle_ID, Vehicle_Name, Vehicle_ Quantity Purchasing_Vehicles, Selling_Vehicles, Release_Date, Vehicle_Rating) VALUES (190, P4, 15, 180, 180, 2022-01-28, 90.85);
INSERT INTO Vehicle_Details (Vehicle_ID, Vehicle_Name, Vehicle_ Quantity Purchasing_Vehicles, Selling_Vehicles, Release_Date, Vehicle_Rating) VALUES (145, P2, 20, 270, 290, 2022-02-18, 80);
INSERT INTO Vehicle_Details (Vehicle_ID, Vehicle_Name, Vehicle_ Quantity Purchasing_Vehicles, Selling_Vehicles, Release_Date, Vehicle_Rating) VALUES (90, P7, 10, 360, 80, 2021-12-25, 180);
INSERT INTO Vehicle_Details (Vehicle_ID, Vehicle_Name, Vehicle_ Quantity Purchasing_Vehicles, Selling_Vehicles, Release_Date, Vehicle_Rating) VALUES (45, P6, 35, 45, -15, 2021-10-15, 80);
INSERT INTO Vehicle_Details (Vehicle_ID, Vehicle_Name, Vehicle_ Quantity Purchasing_Vehicles, Selling_Vehicles, Release_Date, Vehicle_Rating) VALUES (210, P8, 30, 160, -60, 2022-01-28, 95);
INSERT INTO Vehicle_Details (Vehicle_ID, Vehicle_Name, Vehicle_ Quantity Purchasing_Vehicles, Selling_Vehicles, Release_Date, Vehicle_Rating) VALUES (185, P10, 290, 450, 470, 2022-04-11, 80);
以下的SELECT语句显示了上述的 Vehicle_Details 表中插入的记录:
SELECT * FROM Vehicle_Details;
Vehicle_ID | Vehicle_Name | Vehicle_Quantity | Purchasing_Vehicles | Selling_Vehicles | Release_Date | Vehicle_Rating |
---|---|---|---|---|---|---|
140 | P1 | 290 | 45 | 80 | 2022-04-30 | 80 |
190 | P4 | 15 | 180 | 180 | 2022-01-28 | 90.85 |
145 | P2 | 20 | 270 | 290 | 2022-02-18 | 80 |
90 | P7 | 10 | 360 | 80 | 2021-12-25 | 180 |
45 | P6 | 35 | 45 | -15 | 2021-10-15 | 80 |
210 | P8 | 30 | 160 | -60 | 2022-01-28 | 95 |
185 | P10 | 290 | 450 | 470 | 2022-04-11 | 80 |
查询1: 以下SELECT查询在上面的Vehicle_Details表的Vehicle_ID列中使用了RADIANS函数:
SELECT Vehicle_ID, RADIANS(Vehicle_ID) AS Radians value_of_Vehicle_ID FROM Vehicle_Details;
该查询显示了每辆车辆的车辆ID的弧度值。
输出:
Vehicle_ID | Radians value_of_Vehicle_ID |
---|---|
140 | 2.4436 |
190 | 3.316 |
145 | 2.531 |
90 | 1.571 |
45 | 0.785 |
210 | 3.665 |
185 | 3.229 |
查询2: 以下SELECT查询在上面的Vehicle_Details表的Purchasing_Vehicles列中使用了RADIANS函数:
SELECT Purchasing_Vehicles, RADIANS(Purchasing_Vehicles) AS Radians value_of_PurchasingVehicles FROM Vehicle_Details;
这个查询显示购买车辆的弧度值。
**输出:* **
Purchasing_Vehicles | Radians value_of_PurchasingVehicles |
---|---|
45 | 0.785 |
180 | 3.14159 |
270 | 4.712 |
360 | 6.28 |
45 | 0.785 |
160 | 2.793 |
450 | 7.854 |
查询3:下面的SELECT查询对上面的Vehicle_Details表中的Vehicle_Rating列使用RADIANS函数:
SELECT RADIANS(Vehicle_Rating) AS Radians value_of_vehiclerating FROM Vehicle_Details;
这个查询显示了上表中每个车辆评级的弧度值。
输出:
Vehicle_Rating | Radians value_of_vehiclerating |
---|---|
80 | 1.396 |
90.85 | 1.586 |
80 | 1.396 |
180 | 3.14159 |
80 | 1.396 |
95 | 1.658 |
80 | 1.396 |
查询4:下面的SELECT查询使用RADIANS函数对上面的Vehicle_Details表中的and Purchasing_Vehicles和Selling_Vehicles列进行查询:
SELECT Selling_Vehicles, RADIANS(Selling_Vehicles) AS Radians value_of_SellingVehicles FROM Vehicle_Details;
这个查询显示了每辆车销售车辆的弧度值。
输出:
Selling_Vehicles | Radians value_of_SellingVehicles |
---|---|
80 | 1.396 |
180 | 3.14 |
290 | 5.061 |
80 | 1.396 |
-15 | -0.2618 |
-60 | -1.0472 |
470 | 8.203 “` |