How to do SQL inner queries through SQLAlchemy?

What are some cool SQL queries, or tricks that you might not think of being able to do with SQL?

  • I just saw someone who generated a histogram of relative frequencies for categorical variables in pure SQL with a substring of ']]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]' based on the frequency of the variable, which got me wondering, what are some other cool things you can do with your queries?

  • Answer:

    I once saw a SQL query that would solve any sudoku puzzle. But if you want see a lot of really cool SQL tricks, pick up a copy of Joe Celco's SQL for Smarties.

Kevin Edward Kline at Quora Visit the source

Was this solution helpful to you?

Other answers

Check out this question: What are some interesting SQL queries?

Benjamin Darfler

Recursion is what many think is not possible in SQL, and tend towards using Cursors or WHILE loops. But CTE (Common Table Expressions) feature introduced in SQL Server 2005 allows you to create recursive queries, and use it extensively and regularly. Here are some examples: 1. Generating a Factorial series: ;with fact as ( select 1 as fac, 1 as num union all select fac*(num+1), num+1 from fact where num<12) select fac from fact where num=5 2. Generating a Fibonacci Series ;with fibo as ( select 0 as fibA, 0 as fibB, 1 as seed, 1 as num union all select seed+fibA, fibA+fibB, fibA, num+1 from fibo where num<12) select fibA from fibo Check these and more at: http://sqlwithmanoj.com/2011/05/23/cte-recursion-sequence-dates-factorial-fibonacci-series/

Manoj Pandey

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.