【发布时间】:2012-09-18 18:22:11
【问题描述】:
下面的查询:
Select
trunc(create_dtime) as Day,count(create_dtime) as DLs
From Player_Tapjoy
Where
Trunc(Create_Dtime) >= To_Date('2012-sep-01','yyyy-mon-dd')
And Trunc(Create_Dtime) < To_Date('2012-sep-03','yyyy-mon-dd')
Group by trunc(create_dtime)
Union All
Select trunc(create_dtime) as Day,
Count(Create_Dtime) As DLs
From Player_aux_pt
Where
Site = 'AppCircle' And
Trunc(Create_Dtime) >= To_Date('2012-sep-01','yyyy-mon-dd')
And Trunc(Create_Dtime) < To_Date('2012-sep-03','yyyy-mon-dd')
Group By Trunc(Create_Dtime)
给我以下结果:
Day DLs
02-Sep-12 6920
01-Sep-12 6630
02-Sep-12 3009
01-Sep-12 3637
我怎样才能将这些组合起来,以便每天只有一行,并且顺序正确?
【问题讨论】:
-
我的眼睛被那个压痕流血了。
-
@Roger 我不明白你的意思。我的查询太长而无用?
-
他的意思是他不喜欢你格式化代码的方式,很难看出这两个查询之间的区别。有关一些常用的 SQL 格式化标准,请参阅此问题 (stackoverflow.com/questions/519876/sql-formatting-standards)