Subject RE: [firebird-support] Help with query, bit confused
Author Nigel Weeks
> Yeah, I need to also include anoter identifier there like
> login_name='joe' had played with that as well, same results.
> Here is a corrected version.
>
> SELECT COUNT(STATUS) FROM CONTACT_LOGIN_LOG
> WHERE LOGIN_NAME='joe' AND STATUS='Failed' AND LOGGED IN (
> SELECT FIRST 3 LOGGED FROM CONTACT_LOGIN_LOG
> WHERE LOGIN_NAME='joe' ORDER BY LOGGED DESC);
>
> Being that LOGGED is a primary key, I thought having the
> login_name was
> redundant or unneccessary?

Being a primary key in completely irrelevant. You've got three values in an
'IN' condition. Nothing more than that.

>
> > Can you re-describe what you actually want it to give you,
> and we'll see if
> > we can recommend a query.
> > If you want the last three failed logins:
>
> I want to know the number of failed logins based on the last
> 3 attempts.
> So if 2 failed login attempts, I want 2. 3, 3, 1,1.

Fwar. There's a lot of tests for that! There might be a simpler way...
Are you using this for a system that does the following:

"Welcome back, mr. <surname>. There have been three(3) unsuccessful login
attempts since you last logged in."

N.