如何在select语句的别名中使用表数据?

时间:2018-05-31 23:52:01

标签: sql sql-server alias string-concatenation sqlfiddle

我想从我给列SELECT查询返回的列的名称中的记录中引用数据。我试过这个,但它并不喜欢我试图连接到别名的额外SELECT

SELECT Table1.Field1 AS "Pick any " & 
  CAST((SELECT Table2.Field1
  FROM Table2
  WHERE Table2.ID = 1) AS VARCHAR(3))
FROM Table2
WHERE Table1.Field2 = "Value"

我想看到的是:

+------------+
| PICK ANY 4 |
+------------+
| Value1     |
| Value2     |
| Value3     |
| Value4     |
| Value5     |
| Value6     |
+------------+

0 个答案:

没有答案