Publicly available SQL standard documents
For your reference, here is a list of publicly available SQL standard documents. Some are very late draft versions, where the final version is closed source and has to be purchased from ISO or ANSI...
View ArticleThe IS DISTINCT FROM predicate
The SQL-1999 standard specifies a useful IS DISTINCT FROM predicate, that behaves slightly different from the regular not equal comparison predicate. Here is its simple definition: 8.13 <distinct...
View ArticleRow value expressions and the NULL predicate
Row value expressions are something very powerful in SQL. They have been around since the early days of standard SQL, e.g. in SQL 1992, even if not all databases implement them correctly, still today....
View ArticleRow value expressions and the BETWEEN predicate
Now this is a simple example of how SQL clause simulation can get nasty if you want to make use of some more advanced SQL clauses that aren’t supported in all databases. Consider the following...
View ArticleSimulating the SQL standard derived column list
Derived column lists are a fine feature, if your database supports them. The SQL:2008 standard specifies 7.6 <table reference> <table reference> ::= <table factor> | <joined...
View ArticlejOOQ as a PL/Java language
Some people who get in touch with PL/SQL, PL/pgSQL, T-SQL, or any other proprietary procedural language for SQL interaction are probably missing out on a couple of language integration features in the...
View ArticleOracle 12c Goodies: { CROSS | OUTER } APPLY
I can’t believe my eyes. Has this been openly communicated by Oracle? I haven’t seen too many blog posts on that matter. Apart from introducing the awesome SQL Standard OFFSET .. FETCH clause (just...
View ArticleThe Premature Return to SQL
In online communities, the NoSQL topic (much like the ORM topic) is a guarantee to stir emotions. Many emotions are stirred by evangelists on either side for ideological or marketing reasons. Here’s an...
View ArticleProbably the Coolest SQL Feature: Window Functions
Once you get a hang of the very peculiar syntax, SQL is a highly expressive and rich language offering incredible features at a declarative level. One of the coolest features are window functions,...
View ArticleCounting Distinct Records in SQL
The SQL language and its depths… Some of you readers might be aware of MySQL’s capability of counting distinct records through the COUNT() aggregate function. The MySQL documentation reads:...
View ArticleThe Great SQL Implementation Comparison Page
Fortunately, we have SQL standards. Or do we? It’s a well-known secret (or cynical joke) that the SQL standard is yet another SQL dialect among peers. Standards by xkcd On this blog, we have pointed...
View ArticleMySQL Bad Idea #666
MySQL… We’ve blogged about MySQL before. Many times. We’ve shown bad ideas implemented in MySQL here: MySQL Bad Idea #384 MySQL Bad Idea #573 But this beats everything. Check out this Stack Overflow...
View ArticleWhy Did SQLJ Die?
Every now and then, SQLJ pops up somewhere, mostly in a very dusty/enterprisey or in an academic context. If you give SQLJ some thought, though, it isn’t such a bad idea. It is: An ANSI and ISO...
View ArticleThe SQL Language’s Most Missing Feature
SQL is also awesome in many ways. We can write out the most complex truths and facts and have the database tell us the answer in no time. But the SQL language is arguably the most beautiful programming...
View ArticleLesser-Known SQL Features: DEFAULT VALUES
A lesser-known SQL feature is the DEFAULT keyword, which can be used in INSERT and UPDATE statements. Consider the following table, created using standard SQL syntax: CREATE TABLE timestamps ( id...
View ArticleAn MS Access SQL Transformation Odyssey
Recently, we’ve added support for the MS Access database in jOOQ 3.3. This may well have been our hardest integration so far. The MS Access database has its ways, and many of them, too. But luckily,...
View ArticleHow can I do This? – With SQL of Course!
Haven’t we all been wondering: How can I do this? I have these data in Excel and I want to group / sort / assign / combine … While you could probably pull up a Visual Basic script doing the work or...
View ArticleNoSQL? No, SQL! – How to Calculate Running Totals
If anything at all, our jOOQ talks at various JUGs and conferences have revealed mostly one thing: Java developers don’t know SQL. And it isn’t even necessarily our fault. We’re just not exposed to SQL...
View ArticleShould I Put That Table Alias or Not?
Infrequent SQL developers often get confused about when to put parentheses and/or aliases on derived tables. There has been this recent Reddit discussion about the subject, where user Elmhurstlol was...
View ArticleUse MySQL’s Strict Mode on all new Projects!
MySQL is a database that has been bending the SQL standard in ways that make it hard to move off MySQL. What may appear to be a clever technique for vendor lockin (or maybe just oversight of the...
View ArticleDo You Really Understand SQL’s GROUP BY and HAVING clauses?
There are some things in SQL that we simply take for granted without thinking about them properly. One of these things are the GROUP BY and the less popular HAVING clauses. Let’s look at a simple...
View ArticleStill Using Windows 3.1? So why stick to SQL-92?
We’ve been blogging a lot about the merits of modern SQL on the jOOQ blog. Specifically, window functions are one of the most fascinating features. But there are many many others. Markus Winand, author...
View ArticleHow to Extract a Date Part in SQL
The Modern SQL Twitter account (by Markus Winand) published a hint about how to extract a date part in SQL: The right way to get a part of a date/time is: EXTRACT(YEAR FROM CURRENT_DATE) = 2015...
View ArticleUse this Neat Window Function Trick to Calculate Time Differences in a Time...
Whenever you feel that itch… Can’t I calculate this with SQL? The answer is: Yes you can! And you should! Let’s see how… Calculating time differences between rows Let’s consider the following database...
View ArticlejOOQ Tuesdays: Markus Winand is on a Modern SQL Mission
Welcome to the jOOQ Tuesdays series. In this series, we’ll publish an article on the third Tuesday every other month where we interview someone we find exciting in our industry from a jOOQ perspective....
View ArticlejOOQ Tuesdays: Glenn Paulley Gives Insight into SQL’s History
Welcome to the jOOQ Tuesdays series. In this series, we’ll publish an article on the third Tuesday every other month where we interview someone we find exciting in our industry from a jOOQ perspective....
View ArticleTop 10 SQL Dialect Emulations Implemented in jOOQ
The SQL standard is a nice thing. But it’s a standard. And as such, while it may provide good guidelines on how to implement some SQL features, most dialects deviate from it in one way or another...
View ArticleOracle’s OFFSET .. FETCH Can be Slower than Classic ROWNUM Filtering
One of Oracle 12c’s coolest features was the introduction of the SQL standard OFFSET .. FETCH clause, as we can now write things like: SELECT * FROM film ORDER BY film_id FETCH FIRST 1 ROW ONLY This is...
View ArticleUsing IGNORE NULLS With SQL Window Functions to Fill Gaps
I found a very interesting SQL question on Twitter recently: Hi @sfonplsql we have some scenario, Let us 01Jan Mkt Value 100, 02Jan 120, next entry available 25th Jan 125, from 3rd Jan 24 Jan, our...
View ArticleFunctional Dependencies in SQL GROUP BY
The SQL standard knows an interesting feature where you can project any functional dependencies of a primary (or unique) key that is listed in the GROUP BY clause without having to add that functional...
View Article