sql query to sort timestamp -
select b.id st,a.appname name_st , b.no_clicks clicks, b.first_usage ft , b.last_usage lu (select appname, appid oneclick_apps) , (select application_id id, count(*) 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 user_db upper(user_id) upper('e243378') group user_application ) b b.id = a.appid order lu asc
is query....which sorts in ascending order...only in terms of year...what modifications should make sorts entire dd:mm:yyyy hh:mm:ss ?
select b.id st, a.appname name_st, b.no_clicks clicks, b.first_usage ft , b.last_usage lu (select appname, appid oneclick_apps) a, (select application_id id, count(*) 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 user_db upper(user_id) upper('e243378') group user_application ) b b.id = a.appid order lu asc
i see 3 options off top of head.
- don't convert timestamps strings.
- convert timestamps strings sort correctly strings. (yyyy-mm-dd hh:mm:ss)
- include both converted , unconverted timestamps. display converted; sort on unconverted. (a variation on #1)
i prefer #1. if client applications need different display, let them handle it.
Comments
Post a Comment