Home » Tag Archives: SQL (page 4)

Tag Archives: SQL

A Wonderful SQL Feature: Quantified Comparison Predicates (ANY, ALL)

software-development-2-logo

Have you ever wondered about the use-case behind SQL’s ANY (also: SOME) and ALL keywords? You have probably not yet encountered these keywords in the wild. Yet they can be extremely useful. But first, let’s see how they’re defined in the SQL standard. The easy part:           8.7 <quantified comparison predicate> Function Specify a quantified comparison. ...

Read More »

All You Ever Need to Know About Recursive SQL

software-development-2-logo

Oracle SYNONYMs are a great feature. You can implement all sorts of backwards-compatibility tweaks simply by creating SYNONYMs in your database. Consider the following schema:                 CREATE TABLE my_table (col NUMBER(7)); CREATE SYNONYM my_table_old FOR my_table; CREATE SYNONYM my_table_bak FOR my_table_old; Now you can query your same old table through three different names, ...

Read More »

SQL Tip of the Day: Be Wary of SELECT COUNT(*)

software-development-2-logo

Recently, I’ve encountered this sort of query all over the place at a customer site:                     DECLARE v_var NUMBER(10); BEGIN SELECT COUNT(*) INTO v_var FROM table1 JOIN table2 ON table1.t1_id = table2.t1_id JOIN table3 ON table2.t2_id = table3.t2_id ... WHERE some_predicate; IF (v_var = 1) THEN do_something ELSE do_something_else END IF; ...

Read More »

Are You Using SQL PIVOT Yet? You Should!

software-development-2-logo

Every once in a while, we run into these rare SQL issues where we’d like to do something that seems out of the ordinary. One of these things is pivoting rows to columns. A recent question on Stack Overflow by Valiante asked for precisely this. Going from this table:             +------+------------+----------------+-------------------+ | dnId | propNameId ...

Read More »

Java 8 Friday: JavaScript goes SQL with Nashorn and jOOQ

jooq-2-logo

At Data Geekery, we love Java. And as we’re really into jOOQ’s fluent API and query DSL, we’re absolutely thrilled about what Java 8 will bring to our ecosystem. Java 8 Friday Every Friday, we’re showing you a couple of nice new tutorial-style Java 8 features, which take advantage of lambda expressions, extension methods, and other great stuff. You’ll find ...

Read More »

Yet Another 10 Common Mistakes Java Developers Make When Writing SQL (You Won’t BELIEVE the Last One)

software-development-2-logo

(Sorry for that click-bait heading. Couldn’t resist!) We’re on a mission. To teach you SQL. But mostly, we want to teach you how to appreciate SQL. You’ll love it! Getting SQL right or wrong shouldn’t be about that You’re-Doing-It-Wrong™ attitude that can be encountered often when evangelists promote their object of evangelism. Getting SQL right should be about the fun ...

Read More »

Time to break free from the SQL-92 mindset

software-development-2-logo

Are you stuck in the 90s? If you are only using the SQL-92 language reference, then you are overlooking so many great features like: window functions MERGE TRUNCATE INSTEAD OF triggers Some test data In my previous article I imported some CSV Codahale metrics into PostgreSQL for further analysis. Our time series data consists of a total request count and ...

Read More »

The Index You’ve Added is Useless. Why?

software-development-2-logo

Recently, at the office: Bob: I’ve looked into that slow query you’ve told me about yesterday, Alice. I’ve added the indexes you wanted. Everything should be fine now Alice: Thanks Bob. I’ll quickly check … Nope Bob, still slow, it didn’t seem to work Bob: You’re right Alice! It looks like Oracle isn’t picking up the index, for your query ...

Read More »
Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close