select b.id as st,a.appname as name_st ,
b.no_clicks as clicks,
b.first_usage as ft ,
b.last_usage as lu from
(select appname, appid from oneclick_apps) a ,
(SELECT application_id AS id, COUNT(*) AS NO_CLICKS,
TO_CHAR( min(accessed_time),'DD-MM-YYYY hh:mm:ss')
FIRST_USAGE,
TO_CHAR( max(accessed_time),'DD-MM-YYYY hh:mm:ss')
LAST_USAGE
FROM user_db
WHERE upper(user_id) like upper('e243378')
GROUP BY user_application ) b
where b.id = a.appid order by lu asc
是我的查询....按升序排序...仅以年份为单位...我应该做出哪些修改以便对整个dd进行排序:mm:yyyy hh:mm:ss?
答案 0 :(得分:1)
select b.id as st, a.appname as name_st,
b.no_clicks as clicks, b.first_usage as ft , b.last_usage as lu
from (select appname, appid from oneclick_apps) a,
(SELECT application_id AS id, COUNT(*) AS NO_CLICKS,
TO_CHAR( min(accessed_time),'DD-MM-YYYY hh:mm:ss') FIRST_USAGE,
TO_CHAR( max(accessed_time),'DD-MM-YYYY hh:mm:ss') LAST_USAGE
FROM user_db
WHERE upper(user_id) like upper('e243378')
GROUP BY user_application ) b
where b.id = a.appid
order by lu asc
我看到了三个选项。
我更喜欢#1。如果客户端应用程序需要不同的显示,请让他们处理它。
答案 1 :(得分:0)
首先,我不愿意维护你的代码。没有格式化会导致严重的头痛。
好的,让我们看看我们是否可以提供帮助。
为什么不把格式化移到外部范围。
像
这样的东西select b.id as st,
a.appname as name_st ,
b.no_clicks as clicks,
TO_CHAR( b.first_usage,'DD-MM-YYYY hh:mm:ss') as ft ,
TO_CHAR( b.last_usage,'DD-MM-YYYY hh:mm:ss') as lu
from (
select appname,
appid
from oneclick_apps
) a ,
(
SELECT application_id AS id,
COUNT(*) AS NO_CLICKS,
min(accessed_time) FIRST_USAGE,
max(accessed_time) LAST_USAGE
FROM user_db
WHERE upper(user_id) like upper('e243378')
GROUP BY user_application
) b
where b.id = a.appid
order by b.last_usage asc