Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query without max()
Message
De
19/09/2019 08:17:21
 
 
À
19/09/2019 02:42:25
Walter Meester
HoogkarspelPays-Bas
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01670845
Message ID:
01670943
Vues:
65
J'aime (1)
>I don't get the fuss about why subqueries are unreadable. You read them top to bottom and the details are exactly where they are executed while with CTE's the definition and usages could be pages apart. Happy debugging.

Because you don't read them top to bottom if you want to understand. You read them from the inside going out, which means you have to first figure out what is the innermost query. That can be difficult and it's easy to think some clauses are part of one query when they're really part of the containing or contained query.

This conversation reminds me of the difference between what I called the nested and sequential styles of the FROM clause. You can write almost any query using nested JOINs:
FROM TableA
  JOIN TableB
    JOIN TableC
      JOIN TableD
         ON join condition for TableC and TableD
      ON join condition for TableB and TableC
    ON join condition for TableA and TableB
But I find those can get really hard to follow and comprehend and must prefer the sequential style:
FROM TableA
  JOIN TableB
    ON join condition for TableA and TableB
  JOIN TableC
    ON join condition for TableB and TableC
  JOIN TableD
    ON join condition for TableC and TableD
In much the same way, I find that CTEs flatten a query and make it easier to see and comprehend the pieces.

Tamar
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform