postgresql
7.1
current_timestamp
select to_char(current_timestamp, 'YYYY-MM-DD')
select to_char(current_timestamp, 'HH24:MI:SS')
select c.category_id, c.category_name,
s.subcategory_id, s.subcategory_name,
ss.subsubcategory_id, ss.subsubcategory_name
from ec_categories c
left join ec_subcategories s using (category_id)
left join ec_subsubcategories ss on (s.subcategory_id = ss.subcategory_id)
order by c.sort_key, s.sort_key, ss.sort_key
select c.category_id, c.category_name, s.subcategory_id, s.subcategory_name, ss.subsubcategory_id, ss.subsubcategory_name
from ec_cat_mailing_lists m
left join ec_categories c on (m.category_id=c.category_id)
left join ec_subcategories s on (m.subcategory_id=s.subcategory_id)
left join ec_subsubcategories ss on (m.subsubcategory_id=ss.subsubcategory_id)
order by
case when c.category_id is null then 0 else c.sort_key end,
case when s.subcategory_id is null then 0 else s.sort_key end,
case when ss.subcategory_id is null then 0 else ss.sort_key end