select 2在union sql语句中是什么意思?

用户名

我有以下代码,它将两个select语句合并在一起,但是第二个select从select 2开始。

select tax_type, sum(amount) from bill_tax_tbl a (index multi), bill_summ_tbl b where a.customer_no = @customer_no and a.invoice_month = convert(tinyint,datepart(mm,dateadd(mm,-1,convert(datetime,@date)))) and a.job = b.job and a.billing_sub_job = b.billing_sub_job and b.job_group is null group by tax_type union select 2, sum(amount) from bill_tax_tbl a (index multi), bill_summ_tbl b where a.customer_no = @customer_no and tax_type = 1 and a.invoice_month = convert(tinyint,datepart(mm,dateadd(mm,-1,convert(datetime,@date)))) and a.job = b.job and a.billing_sub_job = b.billing_sub_job and b.job_group is null

伊恩·莱尔德(Ian Laird)

2是将在tax_type字段中结束的值常量。

给定表的示例:

+-----+-----+
|  a  |  b  |
+===========+
| 'a' | 'b' |
| 'c' | 'd' |
+------------

查询者:

SELECT a, b from table
UNION
SELECT 'y','z'

将返回:

+-----+-----+
|  a  |  b  |
+===========+
| 'a' | 'b' |
| 'c' | 'd' |
| 'y' | 'z' |
+------------

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章