Subject | Help with query, bit confused |
---|---|
Author | William L. Thomson Jr. |
Post date | 2005-12-27T17:30:02Z |
I want to query the last 3 records to find out the number that have a
status of Failed. I thought the query below would work?
SELECT COUNT(STATUS) FROM CONTACT_LOGIN_LOG
WHERE STATUS='Failed' AND LOGGED IN (
SELECT FIRST 3 LOGGED FROM CONTACT_LOGIN_LOG
WHERE LOGIN_NAME='joe' ORDER BY LOGGED DESC);
Which would accomplish my goal. Return the number of rows with a failed
status out of the last 3 rows of data. With the number being returned
being no greater than 3.
However it does not work that way at all. I get more than 3 rows with
the query? I do not understand why the LOGGED IN select_list does not
work? Should the query not require both conditions to be met? Unless
LOGGED is in the 3 last rows selected. It should not matter if it's
status is failed or not. Since only one of the 2 conditions is true?
Comments, suggestions, or etc are all greatly appreciated.
--
Sincerely,
William L. Thomson Jr.
Obsidian-Studios, Inc.
http://www.obsidian-studios.com
status of Failed. I thought the query below would work?
SELECT COUNT(STATUS) FROM CONTACT_LOGIN_LOG
WHERE STATUS='Failed' AND LOGGED IN (
SELECT FIRST 3 LOGGED FROM CONTACT_LOGIN_LOG
WHERE LOGIN_NAME='joe' ORDER BY LOGGED DESC);
Which would accomplish my goal. Return the number of rows with a failed
status out of the last 3 rows of data. With the number being returned
being no greater than 3.
However it does not work that way at all. I get more than 3 rows with
the query? I do not understand why the LOGGED IN select_list does not
work? Should the query not require both conditions to be met? Unless
LOGGED is in the 3 last rows selected. It should not matter if it's
status is failed or not. Since only one of the 2 conditions is true?
Comments, suggestions, or etc are all greatly appreciated.
--
Sincerely,
William L. Thomson Jr.
Obsidian-Studios, Inc.
http://www.obsidian-studios.com