Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best online SQL tutorial for learning to write complex reporting queries? [closed]

My SQL skills are rather limited and since I find myself working with a DB (Oracle) a lot lately I would like to get beyond the basic select statements.

I want to write queries that do things like get data from multiple tables, sum quantities, compare dates, group, filter etc.

What sites can you recommend for getting SQL reporting skills to a more advanced level?

like image 513
Jeroen Dirks Avatar asked Jun 02 '09 13:06

Jeroen Dirks


People also ask

Which database is best for complex queries?

As your queries are complex, SQL is the way to go. MongoDB is what's known as a NoSQL database. It is very fast, however it sacrifices robustness and has weak relational guarantees. Contrasting, SQL is resistant to outages and guarantees consistency between queries.


5 Answers

I know this isn't online, but it fits your bill to a T:

I would recommend picking up a copy of Anthony Mollinaro's SQL Cookbook. It describes how to do lots of complicated things that go beyond the basic SELECT FROM WHERE . In a prev. life, when doing lots of queries for a prev. job, that book was my life saver and people borrowed that book a lot. It has lots of very clear examples, and they range from the simple (How to retrieve a subset of rows on a table) to the complex (using window functions to generate histograms).

It's not free, but the book will pay for itself rather quickly, and I imagine would answer most of the questions you would have. NOTE: I have no connection with O'Reilly or Mr. Mollinaro, I simply think this book is awesome and ridiculously helpful.

like image 32
J. Polfer Avatar answered Oct 05 '22 23:10

J. Polfer


Pick up Joe Celcko's SQL For Smarties. That's one of the definitive take-your-sql-to-the-next-level books. Otherwise, just keep writing queries.

Make sure you understand joins. Since the beginning of time, my SQL methodology has always been row-count driven - In other words, as I write a complicated query, I'm always #1 making sure it returns the correct number of rows. If your rowcount is correct, then your sums/groups/aggregates will all be correct. And they are VERY easy to mess up.

Make sure you understand the data. Make sure you understand keys and uniqueness so that you can enforce your joins.

You can also read asktom.oracle.com for a lot of really cool SQL trickery. Laurent Schneider is also very cutting-edge sql-wise. I wouldn't be half the DBA/Developer I am today had I not set asktom as my home page for the last 5-6 years.

Finally, make sure you understand set based operations. Think of the result set as a whole, not just a collection of rows. It'll click as you do it. This relates back to the row-count-driven methodology.

like image 85
Neil Kodner Avatar answered Oct 06 '22 01:10

Neil Kodner


Read chapter 20, 21 and 22 of the Oracle data ware house guide: http://download.oracle.com/docs/cd/B28359_01/server.111/b28313/toc.htm . It's about grouping, analytics and the model clause.

like image 29
tuinstoel Avatar answered Oct 06 '22 00:10

tuinstoel


W3 Schools SQL Tutorial is a good place to start. It gives some examples of the different types of joins and details a lot of the functions (i.e. sum, count, avg). I really had to build a foundation in SQL before understanding complex queries.

like image 38
scottm Avatar answered Oct 05 '22 23:10

scottm


I just found a site called SQL Tutorial that I think is pretty good and wanted to share with the community. It is at http://www.sql-tutorial.com/

like image 27
eric.christensen Avatar answered Oct 06 '22 00:10

eric.christensen