|Subject||RE: [firebird-support] Help with query, bit confused|
> On Wed, 2005-12-28 at 09:56 +1100, Nigel Weeks wrote:Righto. Got more coffee. Lets rip this apart and see what's going on.
> > > 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.
> LOGGED in the outer query would equal only those three right?
> Since they
> are primary keys would make the outer query have the equivalent of 3 x
> LOGGED= conditions? For example if LOGGED where an int, and had values
> of 1,2,3. Would the outer query not be restricted to
> returning only rows
> with the primary keys of 1,2,3?
> Now at the moment there are 6 failed entries for joe. When I run the
> above query I get 6. If I just return the rows with * instead of
> COUNT(). I get all records, not just ones in the inner query.
Ok. six failed entries for 'joe'. What are the values of 'LOGGED' for those