Yeah, that is what I am doing now, but that results in two selects, and it's 
causing me to have to rewrite other pieces of the program.  It's a long 
story...  The owners of the business said that "there will never be...", WRONG! 
So, with that in mind, I wrote the reporting tool. Now, it's missing that 
record, and I want to leave all of my other SELECTs from other places intact, 
and I just have to deal with the empty/NULL values, which was already 95% in 
place.  I just have to address a few lines on a bunch of places to address 
searches, etc...


From: Simon Slavin
Sent: Friday, April 5, 2019 09:50 AM
To: SQLite mailing list
Subject: Re: [sqlite] Returning NULL or empty values when the SELECT does not 
satisfy all of the query

On 5 Apr 2019, at 2:45pm, Jose Isaias Cabrera <[email protected]> wrote:

> then do this,
>
> select
> a.*, b.* from t as a join z as b on a.a = b.f
> where a.a = 'p006'
> AND
>  a.idate = (select max(idate) from t where a = a.a)
> AND
>  b.idate = (select max(idate) from z where f = a.a)
> ORDER BY a.a
> ;

For testing purposes, break your SELECT down into single operations.  First do

select max(idate) from t where a = 'p006'
select max(idate) from z where f = 'p006'

Are those values the answers you expected ?  Then plug those answers into

> select
> a.*, b.* from t as a join z as b on a.a = b.f
> where a.a = 'p006'
> AND
>  a.idate = X
> AND
>  b.idate = Y
> ORDER BY a.a

and see whether it does what you expect.
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to