Get SQL queries without typing!!! (Rasgo’s SQL Generator)

Yash Gupta
Data Science Simplified
6 min readAug 1, 2022

Before we begin with how SQL queries can be generated without typing, I’d like you to try understanding and reading this SQL query:

  SELECT first_name, last_name, order_date, amount  FROM customers, orders  WHERE customers.id = orders.customer_id;

Now imagine, that this SQL code might take you 2 minutes to type down. The query is pretty essential for a join if you are someone who has been using SQL for a while. Imagine doing this from tables that have 20 columns each. Finding the right columns to join might add another 2 minutes.

Therefore, if you write another SQL query, that’ll take you another 5 minutes to write.

So essentially, while SQL is good to use and very widely considered the world’s most used Database Querying language, it’s not as efficient as it could be. Writing queries, even complex ones, end up being repetitive because blocks of SQL end up being repeated multiple times.

This is where someone awesome introduced me to the SQL Generator by Rasgo.

Rasgo Docs!

Check out their official website here:

Rasgo developed an SQL generator for database users to put their data tables on the cloud and generate SQL queries for them instantly.

Think Excel. But for SQL Querying!

I got in touch with Graham Girty Rasgo and their Chief Data Scientist Josh Berry, and the marvels that Rasgo has been working on deserve a lot more reach!

The SQL Generator is a free community resource open to everyone and offers a number of different SQL syntax flavors, which is particularly useful for functions like DATE_ADD and DATE_DIFF to work with Time Series Data etc. while ensuring that any and all aggregations, joins, creation or updating commands you need to do in SQL can be generated for you instantaneously.

They say that Rasgo will continue to add more transforms and examples of how to use and that Rasgo is proud to give back to the data community and will continue to show support.

(The data community is very welcoming to help each other and this SQL generator is one of the best things I’ve personally come across.)

This is a game changer for anyone who has not tried SQL yet and needs to use it. If you are someone who needs to use SQL but hasn’t had the chance to learn the language, then merely knowing the logic behind how you want a SQL query to work will be enough for you to get Rasgo’s SQL generator to give you the syntax you need and you can use it in any SQL server you use.

How can you use the SQL generator?

To access the SQL generator, use the following link:

You should get to a page like this:

SQL Generator page

The queries are called transforms, considering how you want to transform your original data.

Step 1: Choose a transform

Consider if you want to filter out data to have only values greater than 0 in a particular numeric column.

Step 2: Upload your table

Upload your table as a CSV or just design your table to be the same as required in the base table.

Step 3: Choose the specifics as required on how the transformation must occur.

Some example specifications are given in the following images:

Cast Transformation
Filter transform

The SQL command is explained under the transform for the user to understand and the dialect can be changed to suit any SQL platform the user prefers.

Step 4: Choose the dialect after choosing the specifications of the transformation:

Step 5: Click generate SQL and let the magic happen!

As you can see, the query is generated and you can just copy it to use it in your work. Queries can be written faster with the SQL Generator because it writes the syntax for you.

I’ve used it in one of my projects and the time it saves is a lot. It helps you focus more on the analytical side of the data and not waste time querying things repeatedly. The entire SQL generator is available with the source code for anyone who wants to add a couple of queries to the larger community.

Another example with a more complicated query!

To generate multiple aggregations;

all you need to enter is the columns and choose the aggregations and the SQL generator offered a pretty straightforward syntax that I could use!

SELECT
Column_3,
Column_2,
AVG(Column_3) as Column_3_AVG,
MEDIAN(Column_3) as Column_3_MEDIAN,
MAX(Column_3) as Column_3_MAX,
MIN(Column_3) as Column_3_MIN,
COUNT(Column_3) as Column_3_COUNT
FROM My_First_Table
GROUP BY Column_3, Column_2

Although the examples are on a base table, the syntaxes are very precise and can help anyone who is in need of SQL queries but does not know how to write one on their own.

Works like a charm! And that’s half of what data science is about, being smart about your work!

For some idea on how you can use SQL in your data analysis, they host a couple of tutorials for you to check out too!

The functioning of the generator seems pretty smooth and I’ve learned that universities like UCLA and William & Mary use it to help their students learn SQL. I think it is imperative that data science enthusiasts today stay in touch with tools like this SQL generator to ensure that they’re being smart in their work and not under-utilizing their time in any way.

SQL querying couldn’t get any easier and Rasgo paves the way for taking SQL up to the next level. Try the SQL generator today.

Let me know what you think about the SQL generator in the comments below!

For more such articles, stay tuned with us as we chart out paths on understanding data and coding and demystify other concepts related to Data Science. Please leave a review down in the comments.

Check out my other articles at:

Do connect with me on LinkedIn at — Yash Gupta — if you want to discuss it further! Leave a clap and comment below to support the blog! Follow for more.

P.S. Do check out the profiles of Graham Girty Rasgo and Josh Berry to learn more about Rasgo!

--

--

Yash Gupta
Data Science Simplified

Lead Analyst at Lognormal Analytics and self-taught Data Scientist! Connect with me at - https://www.linkedin.com/in/yash-gupta-dss