SQL exercises
June 23, 09:39 MSK


forgot password?

Personal page
Developers & Thanks
For employers
Support SQL-EX.RU

SQL Exercises news letters, latest issue

#716 (2018-06-23)

Week news

As the important news can appear and between releases of news letters, I shall use this page for the publication of the information on all changes on the site.
The forum is not so suitable for this purpose since the message there "escapes" and can appear on previous page before it will lose a urgency.
So look in here if you wish to be well informed about last events on the site. The link to this page is in section of news at the main page below a subscription banner.
New version of mobile application from Dmitry Ponomarenko is now available for work with site forums and more. Try this.

Has corrected a bug with checking the exercises:
41 (SELECT, learn) - data from qwrqwr.

The most popular topics of the forum
Topic        Messages
Authors of the week in the forum
Author	Messages
NewEXE		6
XnViev		6
Programmizm	5
Kursist		5
Cordova  	3
Available competitions on query optimization
Exercise	Date	     Author
147	2012-02-23	$erges
159	2012-07-25	anddros
170	2011-07-15	qwrqwr
182	2012-02-16	Baser
192	2012-03-03	Baser
197	2014-11-06	pegoopik
214	2015-06-24	pegoopik
222	2018-02-14	pegoopik
259	2012-07-23	anddros
Additional non-optimization competitions
Exercise	Date	Author/Organizer of competition
71	2010-12-26	anddros (closed)
88	2012-07-12	crescent/Pegoopik  (closed)
91	2012-05-31	smog/$erges
102	2016-07-04	GriGrim/pegoopik
121	2012-07-06	ZrenBy/anddros
153	2010-09-21	Ozzy
Changes among leaders (solved exercises of third stage):
9. mcrain (152, 153, 155)
28. Kursist (158, 192, 215, 229)
Applicants for Top 100 have advanced in rating:
130. hard (141, 489.683)
141. anyman1979 (126, 10.160)
146. pavel1211 (126, 59.576)
160. mitvol (126, 30.121)
211. kattiks (100, 46.951)
244. zda (99, 374.068)
259. Zealdequar (100, 48.347)
Have been certified last week:
VSC (A18215249) [BK] - s. Bol'shoe Soldatskoe, Kurskaya oblast', Rossiya
anyman1979 (B18385756) [AR] - g. Tambov, Rossiya
Number of subscribers - 3038
Number of rating's participants - 12026
Number of second-stage's participants - 3079
Number of third-stage's participants - 127
On the learning stage - 254563
Certified specialists in total - 796

ТОР 20

NoPersonNumber of
Last_SelNumber of
1Krasovskij E.A. (pegoopik)1264227346492851210.25414.1242402018-04-282018-06-22
2Kostomarov A.V. (al29)1252953162422144128.3412266.8982402018-05-182018-06-19
3Kreslavskij O.M. (Arcan)1263229346464090273.280214.6142372018-04-142018-06-21
4Boiko D. (Angellore)12632283364538465236.4073825.1402372018-02-202018-03-23
5Bezhaev A.Yu. (Baser)1262227346432924201.513178.8212342018-05-042018-05-06
6Dubinskij A.V. (_velial)12593073463730932797.3933371.3762282018-05-032018-06-22
7Karasyova N.V. (vlksm)1259225346334354290.336241.6822242018-04-152018-06-19
8Kurochkin P.A. (qwrqwr)1255223346213078255.904164.3922122018-04-152018-06-22
9Doschenko V.N. (mcrain)92321523457624521984.495469.6722072018-06-192018-06-22
10Vyazovetskov A.S. (alex_v)9240161235634361177.45294.1962052018-05-172018-05-17
11Filippkin D.V. (_dimon_)1244115295972737194.554127.9092022016-07-202016-09-29
12Movlyanov A.P. (Oct)7244102958813072353.7232448.8471932017-01-232017-04-03
13Sal'nikov S.A. ($erges)122720625551253317.50514.4981812015-02-022018-01-23
14Kukushkin S.A. (smog)92251632952723681054.5621122.1811532017-10-032018-05-11
15Yatsuk A.A. (Faust_zp)1186255244591984144.150108.8401372012-07-122012-07-30
16Kuznetsov V.S. (herrRo)1171260234181167478.51173.3351222012-02-082013-06-18
17Grinkevich D.L. (Dmitrij Grinkevich)1320410274672059367.128932.3431092017-05-312018-05-22
18Drozdkov A.N. (anddros)51921624445224412.34111.0911082014-07-212015-01-29
19Zajtsev V.S. (Sleeping)192091842746036011040.0531327.686992018-04-172018-04-19
20Shindin A.V. (AlShin)114725223366928408.505777.457992011-05-052014-05-18

Best results for last week

1>Sorokin D.Yu. (cth)9722402446822 Jun 2018
2Mikhalenkov S.V. (black_horse)12632252762422 Jun 2018
3>Agirre Kordova A.K. (Cordova)8831701738022 Jun 2018
4Osin V. (anyman1979)51261201214119 Jun 2018
5>Mityurin V. (mitvol)71261201216022 Jun 2018
6Chukanov V.S. (VSC)5631021267421 Jun 2018
7Chernov D.V. (Kursist)4195100102821 Jun 2018
8>f (eldargm)8810010523422 Jun 2018
9Doschenko V.N. (mcrain)3232909922 Jun 2018
10>Il'inykh T.V. (Tatiana_il)77909537922 Jun 2018
11Nesterkin A. (nestam)69808254620 Jun 2018
12Chesnokov M.S. (VinniL)630707145022 Jun 2018
13>Il'inykh Yu.E. (Yulya_il)66707574322 Jun 2018
14Yurin D.I. (Diman9425)236606178822 Jun 2018
15Kolesnikov (hard)314150513022 Jun 2018
16>Karpeshin E.N. (Zealdequar)210050525922 Jun 2018
17>Petrenko M.M. (Diaboliko)318505382322 Jun 2018
18Savin A.Yu. (mirovingin)28240438919 Jun 2018
19>KsNV (KsNV_)26440468322 Jun 2018
20Bukina E. (Charming_Shusha)415404218222 Jun 2018
21Pupkin (hangry)27404278421 Jun 2018
22Petrenko V.S. (Victor I)22404738618 Jun 2018

Let's learn SQL

MySQL. Usage of query variables

E.A. Krasovskiy

People rather often ask whether there are equivalents for analytic (windowing) functions in MySQL. No, there are not. To replace them, self join queries, complex subqueries, etc, are used. Most of such workarounds turn out to be ineffective.

There are no recursive queries in MySQL either. However, a part of problems usually solved by analytic functions or recursive queries can be handled by features available in MySQL.

One of these features is the unique mechanism of processing variables within a SQL query, which is very unusual for other DBMS. In MySQL, you can declare a variable within a query, change its value, and put it into the result set of the SELECT statement for output. And the most notable thing is, the processing order for query rows, and thus the order values are assigned to variables, can be defined by custom sorting!

Note: this article implies expressions within the SELECT statement are processed in order from left to right; however, there is no confirmation of such a processing order in the official MySQL documentation. You need to keep that in mind when switching from one server version to another. To ensure the required evaluation order, a fake CASE or IF statement can be used.

Read more:
Equivalent of recursive CTEs
Equivalents for analytic functions

Useful links

§ Official communities of the site sql-ex in social networks: SQL Exercises at VK.com and SQL Exercises at LinkedIn.com

§ .
    The resource is positioned as a "handbook" for this site SQL-EX.COM, but can be used irrespective of it also.

§ The following DBMS are used on the site for solving exercises: SQL Server 2012 Express, Oracle Database 11g Express Edition, MariaDB-10.2.13 (compatible with MySQL 8), PostgreSQL 10.3.

§ If you like this site, vote for us:

Week news
SQL exercises
Rambler's Top100
Copyright SQL-EX © 2002-2018. All rights reserved.