derby - Learning SQL ... Is there a better way to write this? -


this question i'm trying answer...

what team names of teams had 1 , 1 player appear in 145 or more games?

here solution.

select name   teams  teamid in (select original.teamid                     appearances original                    teamid not in (select one.teamid                                          appearances one, appearances 2                                         (one.teamid = two.teamid)                                            , (one.playerid <> two.playerid)                                            , (one.gs > 144) , (two.gs > 144))); 

this works, i'm wondering if there cleaner/more efficient way write this. i'm using derby dbms.

i'm not sure if query work. would expect more this:

select name   teams  teamid in         ( select one.teamid            appearances 1           (one.gs > 144)                 , one.teamid not in                  ( select two.teamid                     appearances 2                    (one.teamid = two.teamid)                          , (one.playerid <> two.playerid)                           , (two.gs > 144) ) ); 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -