Service information

Plans

freepaid

Platforms

Description

SQL Genius is an online service that converts English text to SQL and explains SQL queries. It offers both free and paid plans and is accessible through its website.

Examples

💻🔍

Explain Sql Queries

#1
inputs

SELECT first_name, last_name, email

FROM users

WHERE age BETWEEN 25 AND 35

ORDER BY last_name DESC

LIMIT 10;

outputs

Plain English Explanation:

TL;DR: This query gets the first name, last name, and email of 10 users age 25-35, ordered by last name in descending order.

This query selects the first_name, last_name, and email fields from the users table, and filters the results on the condition that the age field is between 25 and 35. Then it orders the results by last_name in descending order, and limits the results to 10.

Questions this query could help answer:

-Which users are age 25-35?

-What is the first name, last name, and email of the 10 youngest users between 25 and 35?

-What is the email address of the user with the longest last name between 25 and 35?

#2
inputs

SELECT CONCAT(first_name, ' ', last_name) AS full_name,

LENGTH(CONCAT(first_name, ' ', last_name)) AS name_length

FROM patients

ORDER BY name_length DESC

LIMIT 1;

outputs

Plain English Explanation:

TL;DR: This query gets the longest full name from the patients table.

The query concatenates the first_name and last_name fields in the patients table and creates a new field called full_name. It then creates a name_length field which is the length of the full_name field.

The query then orders the results by name_length in descending order and limits the output to the first result.

Questions this query could help answer:

-Which patient has the longest full name?

-What is the length of the longest full name in the patients table?

📝🗄️

Convert Text To Sql

inputs

doctor_id INTEGER

first_name VARCHAR(30)

last_name VARCHAR(30)

specialty VARCHAR(25)

patient_id INTEGER 

first_name VARCHAR(30)

last_name VARCHAR(30)

gender CHAR(1)

birth_date DATE

city VARCHAR(30)

province_id CHAR(2)

allergies VARCHAR(80)

height DECIMAL(3, 0)

weight DECIMAL(4, 0)

patient_id INT 

admission_date DATE

discharge_date DATE

diagnosis VARCHAR(50)

attending_doctor_id INT

outputs

--Semi-structured interpretation: Given all the doctors who have been the attending doctor for patients with bee allergies, return the 5 doctors with the most admissions

--Output SQL Query:

SELECT DISTINCT d.doctor_id, d.first_name, d.last_name, count(*) as num_patients

FROM patients p

JOIN admissions a ON p.patient_id = a.patient_id

JOIN doctors d ON a.attending_doctor_id = d.doctor_id

WHERE allergies LIKE '%bee%'

GROUP BY d.doctor_id, d.first_name, d.last_name

ORDER BY num_patients DESC

LIMIT 5

--Example rows

--Doctor ID | First Name | Last Name | Number of Patients

--------------------------------------------------------------

-- 9102 | Allison | Rogers | 17

-- 5561 | Jack | Bauer | 15

-- 3344 | Chloe | O'Brian | 14

Share this page: