此查询按select count(*)的值对结果进行排序。我不希望这种情况发生。我怎么能避免这个?我想按照它们在查询中编写的顺序显示它们。谢谢你的帮助。
这是一条查询:
(select count(*) as num_tweet from [TvPad2-dev].dbo.TWEET where REQUEST_ID = 7
and CREATION_DATE>'2016-02-14 01:00:00.000'
and CREATION_DATE<'2016-02-14 01:29:59.999'
and text like '%arisa%')
union
(select count(*) as num_tweet from [TvPad2-dev].dbo.TWEET where REQUEST_ID = 7
and CREATION_DATE>'2016-02-14 01:30:00.000'
and CREATION_DATE<'2016-02-14 01:59:59.999'
and text like '%arisa%')
答案 0 :(得分:2)
使用UNION ALL。
(select count(*) as num_tweet from [TvPad2-dev].dbo.TWEET where REQUEST_ID = 7
and CREATION_DATE>'2016-02-14 01:00:00.000'
and CREATION_DATE<'2016-02-14 01:29:59.999'
and text like '%arisa%')
union all
(select count(*) as num_tweet from [TvPad2-dev].dbo.TWEET where REQUEST_ID = 7
and CREATION_DATE>'2016-02-14 01:30:00.000'
and CREATION_DATE<'2016-02-14 01:59:59.999'
and text like '%arisa%')
答案 1 :(得分:0)
UNION ALL会做到这一点。如果您将UNION更改为UNION ALL,您将无法获得排序结果。