SQL exercises
April 21, 10:54 MSK


forgot password?

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

SQL Exercises news letters, latest issue

#707 (2018-04-21)

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:
145 (SELECT, rating) - data from selber.
34 (DML) - data from aks_nsk and Gosha
The most popular topics of the forum
Topic        Messages
Authors of the week in the forum
Author	Messages
Cordova		27
vasilyvanc  	21
aks_nsk  	19
qwrqwr  	8
selber  	7
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):
1. al29 (224, 227)
10. alex_v (154, 208, 229)
13. mcrain (169)
19. Sleeping (165, 184)
48. aks_nsk (251)
52. selber (145)
Applicants for Top 100 have advanced in rating:
242. Pusev_Denis (99, 11.284)
340. simba_81 (84, 733.645)
378. iriswind1 (82, 291.315)
Number of subscribers - 3029
Number of rating's participants - 11982
Number of second-stage's participants - 3066
Number of third-stage's participants - 127
On the learning stage - 248747
Certified specialists in total - 791

ТОР 20

NoPersonNumber of
Last_SelNumber of
1Kostomarov A.V. (al29)12462243161321832503.7032266.8982402018-04-172018-04-19
2>Krasovskij E.A. (pegoopik)1263229346462843210.11013.9812372018-04-202018-04-20
3Kreslavskij O.M. (Arcan)1263229346464090273.280214.6142372018-04-142018-04-20
4Boiko D. (Angellore)12632283364538465236.4073825.1402372018-02-202018-03-23
5Bezhaev A.Yu. (Baser)1257225316292636199.875177.3102272017-07-202018-03-01
6Dubinskij A.V. (_velial)1257693463230732793.5243368.3692252018-04-132018-04-19
7Karasyova N.V. (vlksm)1259225346334354290.336241.6822242018-04-152018-04-16
8Kurochkin P.A. (qwrqwr)1255223346213078255.904164.3922122018-04-152018-04-20
9Filippkin D.V. (_dimon_)1244115295972737194.554127.9092022016-07-202016-09-29
10Vyazovetskov A.S. (alex_v)10238154235564333171.16687.9101982018-04-192018-04-20
11Movlyanov A.P. (Oct)7244102958813072353.7232448.8471932017-01-232017-04-03
12Sal'nikov S.A. ($erges)122720625551253317.50514.4981812015-02-022018-01-23
13Doschenko V.N. (mcrain)132221693454623861919.326404.5031772018-04-142018-04-20
14Kukushkin S.A. (smog)92251632952723681054.5621122.1811532017-10-032018-03-15
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-04-20
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

1Vyazovetskov A.S. (alex_v)3238100101020 Apr 2018
2>Yakovlev M.V. (MikhailYakovlev535)55010010118120 Apr 2018
3Sajgakova A.V. (Ametist)62410010155119 Apr 2018
4Novikov A. (Proofgg)8810010518519 Apr 2018
5Boronin M.V. (makc-nv)621909174819 Apr 2018
6Latyntsev N.G. (aks_nsk)31798194820 Apr 2018
7Ariam (Ariam)655731072017 Apr 2018
8>Pantileenko D. (iriswind1)38270737820 Apr 2018
9Kostomarov A.V. (al29)2246606119 Apr 2018
10>Agirre Kordova (Cordova)4452429326520 Apr 2018
11Zalunin D. (dim_zal)37505542620 Apr 2018
12Stepanov A.I. (juanas)35415477117 Apr 2018
13Zajtsev V.S. (Sleeping)22094041919 Apr 2018
14KsNV (KsNV_)25040491019 Apr 2018
15Doschenko V.N. (mcrain)12223141320 Apr 2018
16Koptel'tsev V. (selber)11843145220 Apr 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.