Subject | SQL help? |
---|---|
Author | Lee Jenkins |
Post date | 2004-09-01T18:31:29Z |
I have a Table that has a Date field in it. What I would like to do is get
the distinct number of records where the weekday is Monday. The statement
below returns 196 which is the exact number of individual records where
EXTRACT(WEEKDAY FROM o.OrderDate) = 1. What I want to know is how many
distinctly different monday's there are (in this case there are exactly 2 in
the table i queried on). I hope that I make sense here. Had dental work
this morning and pain killer is kicking in.
SELECT DISTINCT
Count(o.OrderDate)
FROM
OrdersPermanent o
WHERE
o.OrderDate >= '1/1/2004' AND
o.OrderDate <= '12/31/2004' AND
(EXTRACT(WEEKDAY FROM o.OrderDate) = 1)
Thank you,
Lee
the distinct number of records where the weekday is Monday. The statement
below returns 196 which is the exact number of individual records where
EXTRACT(WEEKDAY FROM o.OrderDate) = 1. What I want to know is how many
distinctly different monday's there are (in this case there are exactly 2 in
the table i queried on). I hope that I make sense here. Had dental work
this morning and pain killer is kicking in.
SELECT DISTINCT
Count(o.OrderDate)
FROM
OrdersPermanent o
WHERE
o.OrderDate >= '1/1/2004' AND
o.OrderDate <= '12/31/2004' AND
(EXTRACT(WEEKDAY FROM o.OrderDate) = 1)
Thank you,
Lee