SQL ATN2函数
ATN2是一个数学函数,它返回两个指定数字的反正切值。
ATN2函数的语法
SELECT ATN2(Number1, Number2) AS Alias_Name;
在ATN2语法中,我们需要在函数中传递两个数字,从中我们可以找到反正切的值。
在结构化查询语言中,我们也可以在SELECT查询中使用ATN2函数与表字段一起使用:
SELECT ATN2(Column_Name1, Column_Name2) AS Alias_Name FROM Table_Name;
在这个SELECT查询中,我们需要定义要执行ATN2函数的表的名称和字段。
ATN2函数示例
示例1: 该示例返回指定数字的反正切值:
SELECT ATN2(0.5, 1) AS ATN2_value;
输出:
ATN2_value
---
0.463647609001
例子2: 这个例子返回-0.5和2的反正切值:
SELECT ATN2(-0.5, 2) AS ATN2_value;
输出:
ATN2_value
---
-0.244978663127
示例3: 此示例返回80和110的反正切值:
SELECT ATN2(80, 110) AS ATN2_value;
输出:
ATN2_value
---
0.628796286415
示例4: 这个示例返回两个负数的反正切值:
SELECT ATN2(-2.53, -5.6) AS ATN2_value;
输出:
ATN2_value
---
-2.7172547187517906
示例5: 此示例使用数字和PI函数组合返回弧切函数值:
SELECT ATN2(PI(), 4) AS ATN2_value;
输出:
ATN2_value
---
0.66577375002835382
示例6: 该示例使用ATN2函数与SQL表。 在此示例中,我们将通过该表上的数字字段执行ATN2函数来创建新表:
以下是在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)
);
以下是创建Vehicle_Details表来存储购买和销售车辆详细信息的CREATE语句:
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);
NSERT 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和Vehicle_Quantity列的ATN2函数:
SELECT Vehicle_ID, Vehicle_Quantity ATN2(Vehicle_ID, Vehicle_Quantity) AS ATN2 value_of_Vehicle_ID_ Vehicle_Quantity FROM Vehicle_Details;
这个查询显示了每辆车的id和数量的反正切值。
输出:
Vehicle_ID | Vehicle_Quantity | ATN2 value_of_Vehicle_ID_Vehicle_Quantity |
---|---|---|
140 | 290 | 0.449759 |
190 | 15 | 1.49201 |
145 | 20 | 1.43373 |
90 | 10 | 1.46013 |
45 | 35 | 0.90975 |
210 | 30 | 1.428899 |
185 | 290 | 0.567844 |
查询2: 以下SELECT查询使用上述Vehicle_Details表的Purchasing_Vehicles和Selling_Vehicles列的ATN2函数:
SELECT Purchasing_Vehicles, Selling_Vehicles, ATN2(Purchasing_Vehicles, Selling_Vehicles) AS ATN2 value_of_Purchasing_Selling FROM Vehicle_Details;
这个查询显示了所有购买和销售车辆的反正切值。
输出:
Purchasing_Vehicles | Selling_Vehicles | ATN2 value_of_Purchasing_Selling |
---|---|---|
45 | 80 | 0.51238 |
180 | 180 | 0.78539 |
270 | 290 | 0.74969 |
360 | 80 | 1.35212 |
45 | -15 | 1.89254 |
160 | -60 | 1.92956 |
450 | 470 | 0.76366 |
Query 3: 下面的SELECT查询使用了上述Vehicle_Details表中的Purchasing_Vehicles和Vehicle_Quantity列的ATN2函数:
SELECT Purchasing_Vehicles, Vehicle_Quantity, ATN2(Purchasing_Vehicles, Vehicle_Quantity) AS ATN2 value_of_Purchasing_Quantity FROM Vehicle_Details;
这个查询显示每辆车的购买和数量的反正切值。
输出:
Purchasing_Vehicles | Vehicle_Quantity | ATN2 value_of_Purchasing_Quantity |
---|---|---|
45 | 290 | 0.153944 |
180 | 15 | 1.48765 |
270 | 20 | 1.49685 |
360 | 10 | 1.54302 |
45 | 35 | 0.90975 |
160 | 30 | 1.38544 |
450 | 290 | 0.99833 |
查询4: 以下SELECT查询使用了上述Vehicle_Details表中的ATN2函数和Purchasing_Vehicles和Vehicle_Quantity列:
SELECT Selling_Vehicles, Vehicle_Quantity, ATN2(Selling_Vehicles, Vehicle_Quantity) AS ATN2 value_of_Selling_Quantity FROM Vehicle_Details;
这个查询显示了每辆车的销售和数量的反正切值。
输出:
Selling_Vehicles | Vehicle_Quantity | ATN2 value_of_Selling_Quantity |
---|---|---|
80 | 290 | 0.26916 |
180 | 15 | 1.48765 |
290 | 20 | 1.50193 |
80 | 10 | 1.44644 |
-15 | 35 | -0.40489 |
-60 | 30 | -1.1071 |
470 | 290 | 1.0179 |