
Last chance! 50% off DataCamp Premium
Sale ends in
Buy Now
अभ्यास और ट्रैक अपनी प्रगति को।
Google के साथ जारी रखेंजारी रखकर, आप हमारी उपयोग की शर्तें, हमारी गोपनीयता नीति को स्वीकार करते हैं और यह भी कि आपका डेटा USA में संग्रहीत है।यह चीट शीट हमेशा पास रखें
PDF डाउनलोड करेंइस चीट शीट का कोड ऑनलाइन चलाएं और संपादित करें
कोड चलाएंAlthough SQL languages all share a basic structure, some of the specific commands and styles can differ slightly. Popular dialects include MySQL, SQLite, SQL Server, Oracle SQL, and more. PostgreSQL is a good place to start —since it’s close to standard SQL syntax and is easily adapted to other dialects.
Throughout this cheat sheet, we'll be using the sample data airbnb_listings—denoting rental apartments on Airbnb.
| id | city | country | number_of_rooms | year_listed |
| 1 | Paris | France | 5 | 2018 |
| 2 | Tokyo | Japan | 2 | 2017 |
| 3 | New York | USA | 2 | 2022 |
SELECT *
FROM airbnb_listings;
city column from the tableSELECT city
FROM airbnb_listings;
city and year_listed columns from the tableSELECT city, year_listed
FROM airbnb_listings;
id, city, ordered by the number_of_rooms in ascending orderSELECT city, year_listed
FROM airbnb_listings
ORDER BY number_of_rooms ASC;
id, city, ordered by the number_of_rooms in descending orderSELECT city, year_listed
FROM airbnb_listings
ORDER BY number_of_rooms DESC;
airbnb_listingsSELECT *
FROM airbnb_listings
LIMIT 5;
SELECT DISTINCT city
FROM airbnb_listings;
number_of_rooms is more or equal to 3SELECT *
FROM airbnb_listings
WHERE number_of_rooms >= 3;
number_of_rooms is more than 3SELECT *
FROM airbnb_listings
WHERE number_of_rooms > 3;
number_of_rooms is exactly 3SELECT *
FROM airbnb_listings
WHERE number_of_rooms = 3;
number_of_rooms is lower or equal to 3SELECT *
FROM airbnb_listings
WHERE number_of_rooms <= 3;
number_of_rooms is lower than 3SELECT *
FROM airbnb_listings
WHERE number_of_rooms < 3;
SELECT *
FROM airbnb_listings
WHERE number_of_rooms BETWEEN 3 AND 6;
'Paris'SELECT *
FROM airbnb_listings
WHERE city = 'Paris';
'USA' and in ‘France’SELECT *
FROM airbnb_listings
WHERE country IN ('USA', 'France');
city starts with "j" and where it does not end with "t"SELECT *
FROM airbnb_listings
WHERE city LIKE 'j%' AND city NOT LIKE '%t';
"Paris" where number_of_rooms is bigger than 3SELECT *
FROM airbnb_listings
WHERE city = 'Paris' AND number_of_rooms > 3;
"Paris" OR the ones that were listed after 2012SELECT *
FROM airbnb_listings
WHERE city = 'Paris' OR year_listed > 2012;
Mastering SQL is crucial for effective data management and analysis. To leverage the power of data, your team needs to build strong SQL skills alongside other essential data tools. With DataCamp for Business, you can access comprehensive SQL training resources to upskill your team, ensuring they are well-prepared to navigate the complexities of database management and data analysis.
With our SQL training solutions, your team benefits from:
Investing in SQL training for your team empowers them to make informed decisions, optimize database performance, and efficiently manage your organization’s data assets. Request a demo today to explore how our SQL training solutions can help your team excel.
number_of_rooms is missingSELECT *
FROM airbnb_listings
WHERE number_of_rooms IS NULL;
number_of_rooms is not missingSELECT *
FROM airbnb_listings
WHERE number_of_rooms IS NOT NULL;
SELECT SUM(number_of_rooms)
FROM airbnb_listings;
SELECT AVG(number_of_rooms)
FROM airbnb_listings;
SELECT MAX(number_of_rooms)
FROM airbnb_listings;
SELECT MIN(number_of_rooms)
FROM airbnb_listings;
SELECT country, SUM(number_of_rooms)
FROM airbnb_listings
GROUP BY country;
SELECT country, AVG(number_of_rooms)
FROM airbnb_listings
GROUP BY country;
SELECT country, MAX(number_of_rooms)
FROM airbnb_listings
GROUP BY country;
SELECT country, MIN(number_of_rooms)
FROM airbnb_listings
GROUP BY country;
SELECT country, AVG(number_of_rooms) AS avg_rooms
FROM airbnb_listings
GROUP BY country
ORDER BY avg_rooms ASC;
SELECT country, AVG(number_of_rooms)
FROM airbnb_listings
WHERE country IN ('USA', 'Japan');
GROUP BY country;
SELECT country, COUNT(id) AS number_of_listings
FROM airbnb_listings
GROUP BY country;
SELECT year_listed
FROM airbnb_listings
GROUP BY year_listed
HAVING COUNT(id) > 100;
चीट शीट

चीट शीट

चीट शीट
SQL, also known as Structured Query Language, is a powerful tool to search through large amounts of data and return specific information for analysis. Learning SQL is crucial for anyone aspiring to be a data analyst, data engineer, or data scientist, and helpful in many other fields such as web development or marketing.
In this cheat sheet, you'll find a handy list of functions covering querying data, filtering data, aggregation, and more—all collected from our SQL Fundamentals Skill Track.
To strengthen your SQL and data skills, you may find courses like Data Warehousing Concepts and Database Design helpful. If you’re interested in expanding your knowledge into cloud and data engineering, consider exploring Introduction to Data Engineering or our Azure Fundamentals Track.
To easily run all the example code in this tutorial yourself, you can create a DataLab workbook for free that has the dataset, SQL, and the code samples preconfigured.