From: | Keith Worthington <KeithW(at)NarrowPathInc(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | dow question |
Date: | 2005-12-08 02:03:05 |
Message-ID: | 43979459.9020500@NarrowPathInc.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi All,
I am working on a query which in part is
CASE
WHEN extract(dow from tbl_detail.ship_by_date) = 0
THEN 'Sunday ' || tbl_detail.ship_by_date::text
WHEN extract(dow from tbl_detail.ship_by_date) = 1
THEN 'Monday ' || tbl_detail.ship_by_date::text
WHEN extract(dow from tbl_detail.ship_by_date) = 2
THEN 'Tuesday ' || tbl_detail.ship_by_date::text
WHEN extract(dow from tbl_detail.ship_by_date) = 3
THEN 'Wednesday ' || tbl_detail.ship_by_date::text
WHEN extract(dow from tbl_detail.ship_by_date) = 4
THEN 'Thursday ' || tbl_detail.ship_by_date::text
WHEN extract(dow from tbl_detail.ship_by_date) = 5
THEN 'Friday ' || tbl_detail.ship_by_date::text
WHEN extract(dow from tbl_detail.ship_by_date) = 6
THEN 'Saturday ' || tbl_detail.ship_by_date::text
END AS sort_by_string
Is there a better way to do this? The CASE seems inefficient and wordy
but perhaps not.
I was hoping for
day_name(tbl_detail.ship_by_date) || tbl_detail.ship_by_date::text AS
sort_by_string
but AFAIK day_name(date) or something like it is merely my fantasy. ;-)
--
Kind Regards,
Keith
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Glaesemann | 2005-12-08 03:17:22 | Re: dow question |
Previous Message | Hélder M. Vieira | 2005-12-08 01:37:53 | Locale and pattern matching |