Timeline for Do subqueries add expressive power to SQL queries?
Current License: CC BY-SA 3.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 30, 2013 at 22:34 | answer | added | Erwin Smout | timeline score: 1 | |
Jun 8, 2012 at 1:38 | vote | accept | Patrick87 | ||
Jun 8, 2012 at 0:40 | answer | added | Tegiri Nenashi | timeline score: 9 | |
May 21, 2012 at 20:43 | answer | added | Xodarap | timeline score: 16 | |
Apr 10, 2012 at 16:21 | comment | added | Romuald | @Patrick87 as you pointed it out, it may be difficult to reason directly on SQL which is a concrete language with many features with not-so-clear semantics. For instance, it's possible to use a subquery that return a single tuple with a single attribute as a value (e.g., ... where x = (select max(year) from r)). Such "impure" feature seems to be quite tough to model and may add expressiveness | |
Mar 22, 2012 at 9:54 | history | tweeted | twitter.com/#!/StackCompSci/status/182767139537682432 | ||
Mar 21, 2012 at 14:51 | comment | added | Mark Hurd |
BTW AFAIK in normal SQL the ON clause is required for JOIN s, though a cross product is obtained with just a comma.
|
|
Mar 21, 2012 at 14:44 | comment | added | Mark Hurd |
The normal example I have for requiring a subquery is counting duplicates: select count(*) from (select id from sometable group by id having count(*)>1) d . Because it includes group by I have not put this as an answer.
|
|
Mar 8, 2012 at 18:33 | comment | added | Raphael | @Kevin Are you sure the number of operations needed does not depend on the number of rows? Because we can't have that, can we? | |
Mar 8, 2012 at 16:10 | comment | added | Kevin | @Raphael I'm fairly certain you can even do aggregated values, you just need to do more self-joins and group-bys (making it exponentially larger, but still possible). Not sure how I'd formally prove you can do everything that way, though. | |
Mar 8, 2012 at 6:08 | comment | added | Raphael | My gut tells me that you can always join together everything and select from there as long as you do not need aggregated values. Selecting all entries with a value larger than the average of its column seems to require computing the averge first, therefore needing a subquery. | |
Mar 8, 2012 at 5:55 | history | asked | Patrick87 | CC BY-SA 3.0 |