0

我正在尝试使用一个 SELECT 语句选择多个列,但我尝试过这样但没有奏效。

mysql> SELECT AVG(salaryoffered) "$ offer" AS "Average Salary", MIN(salaryoffered)
"$ offer" AS "Min Salary", MAX(salaryoffered) "$ offer" AS "Max Salary" FROM
interview;

但是,他们确实工作并单独使用 SELECT 调出表格。像这样:

mysql> SELECT AVG(salaryoffered) "$ offer" AS "Average Salary" 
mysql> SELECT MIN(salaryoffered) "$ offer" AS "Min Salary" 
mysql> SELECT MAX(salaryoffered) "$ offer" AS "Max Salary" 
    -> FROM interview;

知道如何将三个表放在一个命令中吗?假设看起来像这样:

+----------------+------------+------------+
| Average Salary | Min Salary | Max Salary |
+----------------+------------+------------+
|      12.080357 |      10.75 |      13.75 |
+----------------+------------+------------+
4

1 回答 1

0

第一个查询也不起作用。尝试这个。

SELECT AVG(salaryoffered) AS "Average Salary", 
MIN(salaryoffered) AS "Min Salary", 
MAX(salaryoffered) AS "Max Salary" 
FROM interview;

如果要添加一些文本,请使用 concat,例如

SELECT concat(AVG(salaryoffered), "$ offered") AS "Average Salary", 
concat(MIN(salaryoffered), "$ offered") AS "Min Salary", 
concat(MAX(salaryoffered), "$ offered") AS "Max Salary" 
FROM interview;
于 2013-07-21T08:38:47.563 回答