Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Query without max()
Message
From
15/09/2019 15:14:03
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
15/09/2019 14:45:29
Walter Meester
HoogkarspelNetherlands
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01670845
Message ID:
01670876
Views:
61
>One thing I really hate about CTE is that you can't nest the result of a CTE query as the inner of another query. Its something I frequently do in our framework to build SQL statements dynamically (our Query Designer). One way to avoid that is to get the CTE in an inline function and abstract it away.
>
>
>SELECT * FROM x
>
>
>You can use the result as a subquery
>
>
>SELECT * FROM (SELECT FROM x) as Y WHERE ...
>
>
>but you can't do this
>
>
>SELECT * FROM (WITH CTE (...) as (...) SELECT * FROM CTE) as Y WHERE ...
>
>
>Or use them as arguments in EXISTS(...), IN(...) etc.
>
>Then you'll have to abstract it away
>
>
>SELECT * FROM (SELECT * FROM dbo.MyCTEFunction(...)) as y WHERE ...
>
>
>YMMV,
>
>Walter,

OK with these last part I can see you are really not aware what a CTE is and what you can do with them. Your biggest problem is with the syntax, you are trying to write it as a subquery.

Let's agree to disagree.
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform