鍍金池/ 教程/ 數(shù)據(jù)庫/ SQL SQRT()函數(shù)
SQL MID()函數(shù)
SQL CONCAT_WS()函數(shù)
SQL SOUNDEX()函數(shù)
SQL OCTET_LENGTH()函數(shù)
SQL CHARACTER_LENGTH()函數(shù)
SQL TO_DAYS()函數(shù)
SQL FROM_DAYS()函數(shù)
SQL SELECT查詢語句
SQL字符串函數(shù)
SQL MINUTE()函數(shù)
SQL EXP(X)函數(shù)
SQL LOCALTIMESTAMP和LOCALTIMESTAMP()函數(shù)
SQL INSERT()函數(shù)
數(shù)據(jù)庫 - 第一范式(1NF)
SQL REVERSE()函數(shù)
SQL SECOND()函數(shù)
SQL ASCII(str)函數(shù)
SQL COS()函數(shù)
SQL丟棄或刪除數(shù)據(jù)庫(DROP DATABASE)
SQL AVG()函數(shù)
SQL GROUP BY(分組)
SQL SPACE()函數(shù)
SQL創(chuàng)建數(shù)據(jù)庫(CREATE DATABASE)
數(shù)據(jù)庫 - 第三范式(3NF)
SQL YEAR()函數(shù)
SQL SIN(X)函數(shù)
SQL MIN()函數(shù)
SQL Distinct關(guān)鍵字
SQL NOT NULL約束
SQL LOG10(X)函數(shù)
SQL DISTINCT重復(fù)處理
SQL臨時表
SQL LTRIM()函數(shù)
SQL WHERE子句
SQL BIT_COUNT()函數(shù)
SQL INSTR()函數(shù)
SQL View(視圖)
SQL CURDATE()函數(shù)
SQL UNION子句/操作符
SQL SUM()函數(shù)
數(shù)據(jù)庫 - 第二范式(2NF)
SQL UCASE()函數(shù)
SQL TIME_TO_SEC()函數(shù)
SQL TAN(X)函數(shù)
SQL ORDER BY排序子句
SQL語法
SQL克隆表
SQL POSITION()函數(shù)
SQL CHAR()函數(shù)
SQL索引約束
SQL DAY()函數(shù)
SQL Having子句
SQL PERIOD_ADD()函數(shù)
SQL POW()函數(shù)
SQL ATAN(X)函數(shù)
SQL WEEK()函數(shù)
SQL DATE_FORMAT()函數(shù)
SQL TIMEDIFF()函數(shù)
SQL INNER JOIN(內(nèi)部連接)
SQL RPAD()函數(shù)
SQL MONTHNAME()函數(shù)
SQL LOCALTIME和LOCALTIME()函數(shù)
SQL FULL JOIN(全連接)
SQL TIMESTAMPADD()函數(shù)
SQL ABS()函數(shù)
SQL操運算符
SQL字符串CONCAT()函數(shù)
SQL TRUNCATE()函數(shù)
SQL排序結(jié)果
SQL GREATEST()函數(shù)
SQL DAYOFYEAR()函數(shù)
SQL SUBSTRING_INDEX()函數(shù)
SQL FORMAT()函數(shù)
SQL AND和OR運算符
SQL LENGTH()函數(shù)
SQL MAKETIME()函數(shù)
SQL DATEDIFF()方法
SQL COT()函數(shù)
SQL ELT()函數(shù)
SQL LEFT JOIN(左連接)
SQL數(shù)據(jù)類型
SQL UPDATE更新查詢
SQL STR_TO_DATE()函數(shù)
SQL OCT()函數(shù)
SQL FLOOR(X)函數(shù)
SQL LOWER()函數(shù)
SQL MOD()函數(shù)
SQL LCASE()函數(shù)
SQL選擇數(shù)據(jù)庫(SELECT Database, USE語句)
SQL RDBMS概念
SQL EXTRACT()函數(shù)
SQL NULL值
SQL唯一約束
SQL HOUR()方法
SQL SIGN(X)函數(shù)
SQL DATE(expr)函數(shù)
SQL實用函數(shù)
SQL從現(xiàn)有表創(chuàng)建表
SQL DATE_SUB()方法
SQL子查詢
SQL TIME_FORMAT()函數(shù)
SQL REPLACE()函數(shù)
SQL LPAD()函數(shù)
SQL EXPORT_SET()函數(shù)
SQL EXCEPT子句
SQL FIELD()函數(shù)
SQL CONVERT_TZ()函數(shù)
SQL邏輯運算符
SQL SEC_TO_TIME()函數(shù)
SQL QUOTE()函數(shù)
SQL CURRENT_TIMESTAMP()方法
SQL QUARTER()函數(shù)
SQL MAKE_SET()函數(shù)
SQL ADDTIME()函數(shù)
SQL MAKEDATE()函數(shù)
SQL HEX()函數(shù)
SQL LEFT()函數(shù)
SQL使用序列(自動遞增)
SQL DEFAULT約束
SQL CURRENT_TIME()函數(shù)
SQL表達式
SQL TIMESTAMP()函數(shù)
SQL NOW()函數(shù)
SQL TOP,LIMIT,ROWNUM子句
SQL RIGHT JOIN(右連接)
SQL CONV()函數(shù)
SQL CHECK約束
SQL INTERVAL()函數(shù)
SQL事務(wù)
SQL STRCMP()函數(shù)
SQL UPPER()函數(shù)
SQL UNHEX()函數(shù)
SQL UTC_TIME()函數(shù)
SQL SUBTIME()函數(shù)
SQL ADDDATE()函數(shù)
SQL PERIOD_DIFF()函數(shù)
SQL REGEXP模式
SQL笛卡爾或交叉連接
SQL BIN(N)函數(shù)
SQL RADIANS()函數(shù)
SQL OCT(N)函數(shù)
SQL DAYNAME()函數(shù)
SQL FIND_IN_SET()函數(shù)
SQL日期函數(shù)
SQL LOAD_FILE()函數(shù)
SQL MAX()函數(shù)
SQL ROUND()函數(shù)
SQL LAST_DAY()函數(shù)
SQL SQRT()函數(shù)
SQL LOCATE()函數(shù)
SQL算術(shù)運算符
SQL索引
SQL CONV(N,from_base,to_base)函數(shù)
SQL Join聯(lián)接
SQL LOG()函數(shù)
SQL數(shù)值函數(shù)
SQL BIT_OR()函數(shù)
SQL自連接
SQL SUBDATE()函數(shù)
SQL創(chuàng)建表(CREATE Table)
SQL DEGREES()函數(shù)
SQL注入
SQL ACOS()函數(shù)
SQL DATE_ADD()和DATE_SUB()方法
SQL YEARWEEK()函數(shù)
SQL BIT_LENGTH()函數(shù)
SQL刪除表(DROP或DELETE Table)
SQL教程
SQL STD()函數(shù)
SQL別名語法
SQL TIME()函數(shù)
SQL WEEKOFYEAR()函數(shù)
SQL SYSDATE()函數(shù)
SQL MICROSECOND()函數(shù)
SQL RDBMS數(shù)據(jù)庫
SQL DAYOFMONTH()函數(shù)
SQL ORD()函數(shù)
SQL SUBSTRING()函數(shù)
SQL INTERSECT子句
SQL RAND()函數(shù)
SQL ATAN2()函數(shù)
SQL TIMESTAMPDIFF()函數(shù)
SQL UTC_DATE()函數(shù)
SQL FROM_UNIXTIME()函數(shù)
SQL ALTER TABLE(修改表)
SQL FORMAT(X,D)函數(shù)
SQL UNIX_TIMESTAMP()函數(shù)
SQL BIT_AND()函數(shù)
SQL DAYOFWEEK()函數(shù)
SQL LIKE子句
SQL約束
SQL比較運算符
SQL INSERT INTO插入查詢
SQL外鍵
SQL CONCAT()函數(shù)
SQL CEIL()函數(shù)
SQL LEAST()函數(shù)
SQL RIGHT()函數(shù)
SQL REPEAT()函數(shù)
SQL CURRENT_DATE()函數(shù)
SQL SQRT(X)函數(shù)
SQL DELETE刪除查詢
SQL CURTIME()函數(shù)
SQL TRUNCATE TABLE(截斷表)
SQL UTC_TIMESTAMP()函數(shù)
SQL ASIN(X)函數(shù)
SQL主鍵
SQL CHAR_LENGTH()函數(shù)
SQL WEEKDAY()函數(shù)
SQL PI()函數(shù)
SQL MONTH()函數(shù)
SQL通配符運算符
SQL TRIM()函數(shù)

SQL SQRT()函數(shù)

SQL SQRT函數(shù)用來找出任何數(shù)的平方根。您可以使用SELECT語句來找出任何數(shù)的平方根如下:

SQL>  select SQRT(16);
+----------+
| SQRT(16) |
+----------+
| 4.000000 |
+----------+
1 row in set (0.00 sec)

你所看到的是浮點值,因為在這里SQL內(nèi)部操縱會平方根浮點數(shù)據(jù)類型。

可以使用SQRT函數(shù)來計算各種記錄的平方根。理解SQRT函數(shù)更加詳細考慮employee_tbl表,其由具有以下記錄:

SQL> SELECT * FROM employee_tbl;
+------+------+------------+--------------------+
| id   | name | work_date  | daily_typing_pages |
+------+------+------------+--------------------+
|    1 | John | 2007-01-24 |                250 |
|    2 | Ram  | 2007-05-27 |                220 |
|    3 | Jack | 2007-05-06 |                170 |
|    3 | Jack | 2007-04-06 |                100 |
|    4 | Jill | 2007-04-06 |                220 |
|    5 | Zara | 2007-06-06 |                300 |
|    5 | Zara | 2007-02-06 |                350 |
+------+------+------------+--------------------+
7 rows in set (0.00 sec)

現(xiàn)在假設(shè)基于上述表要計算全部dialy_typing_pages的平方根, 那么你可以使用以下命令:

SQL> SELECT name, SQRT(daily_typing_pages)
    -> FROM employee_tbl;
+------+--------------------------+
| name | SQRT(daily_typing_pages) |
+------+--------------------------+
| John |                15.811388 |
| Ram  |                14.832397 |
| Jack |                13.038405 |
| Jack |                10.000000 |
| Jill |                14.832397 |
| Zara |                17.320508 |
| Zara |                18.708287 |
+------+--------------------------+
7 rows in set (0.00 sec)