Nice :)
 
> To: sqlite-users@sqlite.org
> From: itandet...@mvps.org
> Date: Sat, 25 Sep 2010 10:21:18 -0400
> Subject: Re: [sqlite] Need help with self-join (I think)
> 
> Kristoffer Danielsson <kristoffer.daniels...@live.se> wrote:
> >> From: oliver....@web.de
> >> a little mistake - here's the correction:
> >> 
> >> SELECT DISTINCT t.Year, b.Name,
> >> (SELECT SomeValue FROM Test INNER JOIN Test2 WHERE Year = t.Year AND Name =
> >> b.Name) AS SomeValue
> >> FROM Test t
> >> CROSS JOIN (SELECT DISTINCT Name FROM Test) b
> >> ;
> >
> > Ah, this one's easier to follow.
> 
> See how you like this one:
> 
> select *
> from (select distinct year from Test) as AllYears
> join (select distinct name from Test) as AllNames
> left join Test t on (t.year=AllYears.Year and t.name=AllNames.name)
> left join Test2 t2 on (t.TestId = t2.TestId);
> 
> -- 
> Igor Tandetnik
> 
> 
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
                                          
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to