我对 Oracle 很陌生(几个小时)。我的经验全是 MySQL。
我的查询在我看来是非常基本的,但是 group by 似乎并没有返回预期的结果。经过几个小时的搜索,我希望这里有人可以提供帮助!
这是我的代码:
SELECT trunc(start_time), display_name, count(*)
FROM TblName
WHERE (DISPLAY_NAME like '%Advise the customer how they can change their marketing preferences%')
OR (DISPLAY_NAME like '%Inform customer on relevant ads%')
OR (DISPLAY_NAME like '%Is the customer requesting to block%')
GROUP BY start_time, display_name
HAVING start_time >= '2013-10-24';
我得到的结果将有多个行,它们具有相同的 start_time、display_name 和 1 的计数。超过 400 行在查询中返回并且所有的计数都为 1。
编辑:以下是结果。所以我现在明白为什么 group by 不能正常工作。在 MySQL 中,我会使用 date(start_time) 来纠正这个问题。甲骨文有类似的东西吗?
11-SEP-13 02.16.42.809000000 PM Advise the customer how they can change their marketing preferences. 1
25-SEP-13 11.56.05.814000000 AM Advise the customer how they can change their marketing preferences. 1
26-SEP-13 11.17.29.737000000 AM Advise the customer how they can change their marketing preferences. 1
24-OCT-13 10.53.17.941000000 AM Advise the customer how they can change their marketing preferences. 1
26-OCT-13 10.24.25.099000000 AM Is the customer requesting to block? 1
23-OCT-13 08.28.58.234000000 PM Advise the customer how they can change their marketing preferences. 1
25-OCT-13 02.50.49.329000000 PM Inform customer on relevant ads 1
26-OCT-13 11.46.45.686000000 AM Advise the customer how they can change their marketing preferences. 1
28-OCT-13 10.12.31.613000000 AM Inform customer on relevant ads 1
25-OCT-13 11.38.24.570000000 AM Inform customer on relevant ads 1
提前致谢!