instructions stringlengths 16 224 | input stringlengths 114 4.5k | output stringlengths 18 557 |
|---|---|---|
How many students does each advisor have? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : How many students does each advisor have? | SELECT advisor, COUNT_BIG(*) FROM Student GROUP BY advisor |
Which advisor has most number of students? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : Which advisor has most number of students? | SELECT TOP 1 advisor FROM Student GROUP BY advisor ORDER BY CASE WHEN COUNT_BIG(*) IS NULL THEN 1 ELSE 0 END DESC, COUNT_BIG(*) DESC |
Give the advisor with the most students. | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : Give the advisor with the most students. | SELECT TOP 1 advisor FROM Student GROUP BY advisor ORDER BY CASE WHEN COUNT_BIG(*) IS NULL THEN 1 ELSE 0 END DESC, COUNT_BIG(*) DESC |
How many students have cat allergies? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : How many students have cat allergies? | SELECT COUNT_BIG(*) FROM Has_allergy WHERE Allergy = [Cat] |
How many students are affected by cat allergies? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : How many students are affected by cat allergies? | SELECT COUNT_BIG(*) FROM Has_allergy WHERE Allergy = [Cat] |
Show all student IDs who have at least two allergies. | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : Show all student IDs who have at least two allergies. | SELECT StuID FROM Has_allergy GROUP BY StuID HAVING COUNT_BIG(*) >= 2 |
What are the students ids of students who have more than one allergy? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : What are the students ids of students who have more than o... | SELECT StuID FROM Has_allergy GROUP BY StuID HAVING COUNT_BIG(*) >= 2 |
What are the student ids of students who don't have any allergies? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : What are the student ids of students who don't have any al... | SELECT StuID FROM Student EXCEPT SELECT StuID FROM Has_allergy |
Which students are unaffected by allergies? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : Which students are unaffected by allergies? | SELECT StuID FROM Student EXCEPT SELECT StuID FROM Has_allergy |
How many female students have milk or egg allergies? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : How many female students have milk or egg allergies? | SELECT COUNT_BIG(*) FROM has_allergy AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T2.sex = [F] AND T1.allergy = [Milk] OR T1.allergy = [Eggs] |
How many students who are female are allergic to milk or eggs? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : How many students who are female are allergic to milk or e... | SELECT COUNT_BIG(*) FROM has_allergy AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T2.sex = [F] AND T1.allergy = [Milk] OR T1.allergy = [Eggs] |
How many students have a food allergy? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : How many students have a food allergy? | SELECT COUNT_BIG(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy = T2.allergy WHERE T2.allergytype = [food] |
How many students are affected by food related allergies? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : How many students are affected by food related allergies? | SELECT COUNT_BIG(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy = T2.allergy WHERE T2.allergytype = [food] |
Which allergy has most number of students affected? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : Which allergy has most number of students affected? | SELECT TOP 1 Allergy FROM Has_allergy GROUP BY Allergy ORDER BY CASE WHEN COUNT_BIG(*) IS NULL THEN 1 ELSE 0 END DESC, COUNT_BIG(*) DESC |
Which allergy is the most common? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : Which allergy is the most common? | SELECT TOP 1 Allergy FROM Has_allergy GROUP BY Allergy ORDER BY CASE WHEN COUNT_BIG(*) IS NULL THEN 1 ELSE 0 END DESC, COUNT_BIG(*) DESC |
Show all allergies with number of students affected. | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : Show all allergies with number of students affected. | SELECT Allergy, COUNT_BIG(*) FROM Has_allergy GROUP BY Allergy |
How many students have each different allergy? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : How many students have each different allergy? | SELECT Allergy, COUNT_BIG(*) FROM Has_allergy GROUP BY Allergy |
Show all allergy type with number of students affected. | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : Show all allergy type with number of students affected. | SELECT T2.allergytype, COUNT_BIG(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy = T2.allergy GROUP BY T2.allergytype |
How many students are affected by each allergy type? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : How many students are affected by each allergy type? | SELECT T2.allergytype, COUNT_BIG(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy = T2.allergy GROUP BY T2.allergytype |
Find the last name and age of the student who has allergy to both milk and cat. | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : Find the last name and age of the student who has allergy ... | SELECT lname, age FROM Student WHERE StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy = [Milk] INTERSECT SELECT StuID FROM Has_allergy WHERE Allergy = [Cat]) |
What are the last names and ages of the students who are allergic to milk and cat? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : What are the last names and ages of the students who are a... | SELECT lname, age FROM Student WHERE StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy = [Milk] INTERSECT SELECT StuID FROM Has_allergy WHERE Allergy = [Cat]) |
What are the allergies and their types that the student with first name Lisa has? And order the result by name of allergies. | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : What are the allergies and their types that the student wi... | SELECT T1.Allergy, T1.AllergyType FROM Allergy_type AS T1 JOIN Has_allergy AS T2 ON T1.Allergy = T2.Allergy JOIN Student AS T3 ON T3.StuID = T2.StuID WHERE T3.Fname = [Lisa] ORDER BY CASE WHEN T1.Allergy IS NULL THEN 1 ELSE 0 END, T1.Allergy |
What are the allergies the girl named Lisa has? And what are the types of them? Order the result by allergy names. | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : What are the allergies the girl named Lisa has? And what a... | SELECT T1.Allergy, T1.AllergyType FROM Allergy_type AS T1 JOIN Has_allergy AS T2 ON T1.Allergy = T2.Allergy JOIN Student AS T3 ON T3.StuID = T2.StuID WHERE T3.Fname = [Lisa] ORDER BY CASE WHEN T1.Allergy IS NULL THEN 1 ELSE 0 END, T1.Allergy |
Find the first name and gender of the student who has allergy to milk but not cat. | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : Find the first name and gender of the student who has alle... | SELECT fname, sex FROM Student WHERE StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy = [Milk] EXCEPT SELECT StuID FROM Has_allergy WHERE Allergy = [Cat]) |
What are the first name and gender of the students who have allergy to milk but can put up with cats? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : What are the first name and gender of the students who hav... | SELECT fname, sex FROM Student WHERE StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy = [Milk] EXCEPT SELECT StuID FROM Has_allergy WHERE Allergy = [Cat]) |
Find the average age of the students who have allergies with food and animal types. | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : Find the average age of the students who have allergies wi... | SELECT AVG(age) FROM Student WHERE StuID IN (SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = [food] INTERSECT SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = [animal]) |
How old are the students with allergies to food and animal types on average? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : How old are the students with allergies to food and animal... | SELECT AVG(age) FROM Student WHERE StuID IN (SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = [food] INTERSECT SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = [animal]) |
List the first and last name of the students who do not have any food type allergy. | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : List the first and last name of the students who do not ha... | SELECT fname, lname FROM Student WHERE NOT StuID IN (SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = [food]) |
What is the full name of each student who is not allergic to any type of food. | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : What is the full name of each student who is not allergic ... | SELECT fname, lname FROM Student WHERE NOT StuID IN (SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = [food]) |
Find the number of male (sex is 'M') students who have some food type allery. | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : Find the number of male (sex is 'M') students who have som... | SELECT COUNT_BIG(*) FROM Student WHERE sex = [M] AND StuID IN (SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = [food]) |
How many male students (sex is 'M') are allergic to any type of food? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : How many male students (sex is 'M') are allergic to any ty... | SELECT COUNT_BIG(*) FROM Student WHERE sex = [M] AND StuID IN (SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = [food]) |
Find the different first names and cities of the students who have allergy to milk or cat. | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : Find the different first names and cities of the students ... | SELECT DISTINCT T1.fname, T1.city_code FROM Student AS T1 JOIN Has_Allergy AS T2 ON T1.stuid = T2.stuid WHERE T2.Allergy = [Milk] OR T2.Allergy = [Cat] |
What are the distinct first names and cities of the students who have allergy either to milk or to cat? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : What are the distinct first names and cities of the studen... | SELECT DISTINCT T1.fname, T1.city_code FROM Student AS T1 JOIN Has_Allergy AS T2 ON T1.stuid = T2.stuid WHERE T2.Allergy = [Milk] OR T2.Allergy = [Cat] |
Find the number of students who are older than 18 and do not have allergy to either food or animal. | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : Find the number of students who are older than 18 and do n... | SELECT COUNT_BIG(*) FROM Student WHERE age > 18 AND NOT StuID IN (SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = [food] OR T2.allergytype = [animal]) |
How many students are over 18 and do not have allergy to food type or animal type? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : How many students are over 18 and do not have allergy to f... | SELECT COUNT_BIG(*) FROM Student WHERE age > 18 AND NOT StuID IN (SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = [food] OR T2.allergytype = [animal]) |
Find the first name and major of the students who are not allegry to soy. | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : Find the first name and major of the students who are not ... | SELECT fname, major FROM Student WHERE NOT StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy = [Soy]) |
What are the first name and major of the students who are able to consume soy? | -- Tables de la base de données (T-SQL) --
TABLE [student] (
[stuid] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[age] INT,
[sex] NVARCHAR(MAX),
[major] INT,
[advisor] INT,
[city code] NVARCHAR(MAX)
);
Question : What are the first name and major of the students who are ... | SELECT fname, major FROM Student WHERE NOT StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy = [Soy]) |
A list of the top 5 countries by number of invoices. List country name and number of invoices. | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 5 billing_country, COUNT_BIG(*) FROM invoices GROUP BY billing_country ORDER BY CASE WHEN COUNT_BIG(*) IS NULL THEN 1 ELSE 0 END DESC, COUNT_BIG(*) DESC |
What are the top 5 countries by number of invoices and how many do they have? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 5 billing_country, COUNT_BIG(*) FROM invoices GROUP BY billing_country ORDER BY CASE WHEN COUNT_BIG(*) IS NULL THEN 1 ELSE 0 END DESC, COUNT_BIG(*) DESC |
A list of the top 8 countries by gross/total invoice size. List country name and gross invoice size. | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 8 billing_country, SUM(total) FROM invoices GROUP BY billing_country ORDER BY CASE WHEN SUM(total) IS NULL THEN 1 ELSE 0 END DESC, SUM(total) DESC |
What are the names of the top 8 countries by total invoice size and what are those sizes? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 8 billing_country, SUM(total) FROM invoices GROUP BY billing_country ORDER BY CASE WHEN SUM(total) IS NULL THEN 1 ELSE 0 END DESC, SUM(total) DESC |
A list of the top 10 countries by average invoice size. List country name and average invoice size. | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 10 billing_country, AVG(total) FROM invoices GROUP BY billing_country ORDER BY CASE WHEN AVG(total) IS NULL THEN 1 ELSE 0 END DESC, AVG(total) DESC |
What are the names of the countries and average invoice size of the top countries by size? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 10 billing_country, AVG(total) FROM invoices GROUP BY billing_country ORDER BY CASE WHEN AVG(total) IS NULL THEN 1 ELSE 0 END DESC, AVG(total) DESC |
Find out 5 customers who most recently purchased something. List customers' first and last name. | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 5 T1.first_name, T1.last_name FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id ORDER BY CASE WHEN T2.invoice_date IS NULL THEN 1 ELSE 0 END DESC, T2.invoice_date DESC |
What are the first and last names of the 5 customers who purchased something most recently? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 5 T1.first_name, T1.last_name FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id ORDER BY CASE WHEN T2.invoice_date IS NULL THEN 1 ELSE 0 END DESC, T2.invoice_date DESC |
Find out the top 10 customers by total number of orders. List customers' first and last name and the number of total orders. | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 10 T1.first_name, T1.last_name, COUNT_BIG(*) FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id GROUP BY T1.id ORDER BY CASE WHEN COUNT_BIG(*) IS NULL THEN 1 ELSE 0 END DESC, COUNT_BIG(*) DESC |
What are the top 10 customers' first and last names by total number of orders and how many orders did they make? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 10 T1.first_name, T1.last_name, COUNT_BIG(*) FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id GROUP BY T1.id ORDER BY CASE WHEN COUNT_BIG(*) IS NULL THEN 1 ELSE 0 END DESC, COUNT_BIG(*) DESC |
List the top 10 customers by total gross sales. List customers' first and last name and total gross sales. | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 10 T1.first_name, T1.last_name, SUM(T2.total) FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id GROUP BY T1.id ORDER BY CASE WHEN SUM(T2.total) IS NULL THEN 1 ELSE 0 END DESC, SUM(T2.total) DESC |
What are the top 10 customers' first and last names with the highest gross sales, and also what are the sales? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 10 T1.first_name, T1.last_name, SUM(T2.total) FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id GROUP BY T1.id ORDER BY CASE WHEN SUM(T2.total) IS NULL THEN 1 ELSE 0 END DESC, SUM(T2.total) DESC |
List the top 5 genres by number of tracks. List genres name and total tracks. | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 5 T1.name, COUNT_BIG(*) FROM genres AS T1 JOIN tracks AS T2 ON T2.genre_id = T1.id GROUP BY T1.id ORDER BY CASE WHEN COUNT_BIG(*) IS NULL THEN 1 ELSE 0 END DESC, COUNT_BIG(*) DESC |
How many tracks does each genre have and what are the names of the top 5? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 5 T1.name, COUNT_BIG(*) FROM genres AS T1 JOIN tracks AS T2 ON T2.genre_id = T1.id GROUP BY T1.id ORDER BY CASE WHEN COUNT_BIG(*) IS NULL THEN 1 ELSE 0 END DESC, COUNT_BIG(*) DESC |
List every album's title. | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT title FROM albums |
What are the titles of all the albums? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT title FROM albums |
List every album ordered by album title in ascending order. | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT title FROM albums ORDER BY CASE WHEN title IS NULL THEN 1 ELSE 0 END, title |
What are the titles of all the albums alphabetically ascending? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT title FROM albums ORDER BY CASE WHEN title IS NULL THEN 1 ELSE 0 END, title |
List every album whose title starts with A in alphabetical order. | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT title FROM albums WHERE title LIKE 'A%' ORDER BY CASE WHEN title IS NULL THEN 1 ELSE 0 END, title |
What are the titles of all albums that start with A in alphabetical order? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT title FROM albums WHERE title LIKE 'A%' ORDER BY CASE WHEN title IS NULL THEN 1 ELSE 0 END, title |
List the customers first and last name of 10 least expensive invoices. | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 10 T1.first_name, T1.last_name FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id ORDER BY CASE WHEN total IS NULL THEN 1 ELSE 0 END, total |
What are the first and last names of the customers with the 10 cheapest invoices? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 10 T1.first_name, T1.last_name FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id ORDER BY CASE WHEN total IS NULL THEN 1 ELSE 0 END, total |
List total amount of invoice from Chicago, IL. | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT SUM(total) FROM invoices WHERE billing_city = [Chicago] AND billing_state = [IL] |
What are the total amount of money in the invoices billed from Chicago, Illinois? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT SUM(total) FROM invoices WHERE billing_city = [Chicago] AND billing_state = [IL] |
List the number of invoices from Chicago, IL. | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT COUNT_BIG(*) FROM invoices WHERE billing_city = [Chicago] AND billing_state = [IL] |
How many invoices were billed from Chicago, IL? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT COUNT_BIG(*) FROM invoices WHERE billing_city = [Chicago] AND billing_state = [IL] |
List the number of invoices from the US, grouped by state. | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT billing_state, COUNT_BIG(*) FROM invoices WHERE billing_country = [USA] GROUP BY billing_state |
How many invoices were billed from each state? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT billing_state, COUNT_BIG(*) FROM invoices WHERE billing_country = [USA] GROUP BY billing_state |
List the state in the US with the most invoices. | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 1 billing_state, COUNT_BIG(*) FROM invoices WHERE billing_country = [USA] GROUP BY billing_state ORDER BY CASE WHEN COUNT_BIG(*) IS NULL THEN 1 ELSE 0 END DESC, COUNT_BIG(*) DESC |
What are the states with the most invoices? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 1 billing_state, COUNT_BIG(*) FROM invoices WHERE billing_country = [USA] GROUP BY billing_state ORDER BY CASE WHEN COUNT_BIG(*) IS NULL THEN 1 ELSE 0 END DESC, COUNT_BIG(*) DESC |
List the number of invoices and the invoice total from California. | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT billing_state, COUNT_BIG(*), SUM(total) FROM invoices WHERE billing_state = [CA] |
What is the number of invoices and total money billed in them from CA? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT billing_state, COUNT_BIG(*), SUM(total) FROM invoices WHERE billing_state = [CA] |
List Aerosmith's albums. | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT T1.title FROM albums AS T1 JOIN artists AS T2 ON T1.artist_id = T2.id WHERE T2.name = [Aerosmith] |
What are the titles of all the Aerosmith albums? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT T1.title FROM albums AS T1 JOIN artists AS T2 ON T1.artist_id = T2.id WHERE T2.name = [Aerosmith] |
How many albums does Billy Cobham has? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT COUNT_BIG(*) FROM albums AS T1 JOIN artists AS T2 ON T1.artist_id = T2.id WHERE T2.name = [Billy Cobham] |
How many albums has Billy Cobam released? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT COUNT_BIG(*) FROM albums AS T1 JOIN artists AS T2 ON T1.artist_id = T2.id WHERE T2.name = [Billy Cobham] |
Eduardo Martins is a customer at which company? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT company FROM customers WHERE first_name = [Eduardo] AND last_name = [Martins] |
What is the company where Eduardo Martins is a customer? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT company FROM customers WHERE first_name = [Eduardo] AND last_name = [Martins] |
What is Astrid Gruber's email and phone number? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT email, phone FROM customers WHERE first_name = [Astrid] AND last_name = [Gruber] |
What is the email and phone number of Astrid Gruber the customer? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT email, phone FROM customers WHERE first_name = [Astrid] AND last_name = [Gruber] |
How many customers live in Prague city? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT COUNT_BIG(*) FROM customers WHERE city = [Prague] |
How many customers live in the city of Prague? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT COUNT_BIG(*) FROM customers WHERE city = [Prague] |
How many customers in state of CA? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT COUNT_BIG(*) FROM customers WHERE state = [CA] |
How many customers are from California? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT COUNT_BIG(*) FROM customers WHERE state = [CA] |
What country does Roberto Almeida live? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT country FROM customers WHERE first_name = [Roberto] AND last_name = [Almeida] |
In which country does Roberto Almeida? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT country FROM customers WHERE first_name = [Roberto] AND last_name = [Almeida] |
List the name of albums that are released by aritist whose name has 'Led' | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT T2.title FROM artists AS T1 JOIN albums AS T2 ON T1.id = T2.artist_id WHERE T1.name LIKE '%Led%' |
What is the title of the album that was released by the artist whose name has the phrase 'Led'? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT T2.title FROM artists AS T1 JOIN albums AS T2 ON T1.id = T2.artist_id WHERE T1.name LIKE '%Led%' |
How many customers does Steve Johnson support? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT COUNT_BIG(*) FROM employees AS T1 JOIN customers AS T2 ON T2.support_rep_id = T1.id WHERE T1.first_name = [Steve] AND T1.last_name = [Johnson] |
What is the count of customers that Steve Johnson supports? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT COUNT_BIG(*) FROM employees AS T1 JOIN customers AS T2 ON T2.support_rep_id = T1.id WHERE T1.first_name = [Steve] AND T1.last_name = [Johnson] |
What is the title, phone and hire date of Nancy Edwards? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT title, phone, hire_date FROM employees WHERE first_name = [Nancy] AND last_name = [Edwards] |
What is the title, phone number and hire date for the employee named Nancy Edwards? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT title, phone, hire_date FROM employees WHERE first_name = [Nancy] AND last_name = [Edwards] |
find the full name of employees who report to Nancy Edwards? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT T2.first_name, T2.last_name FROM employees AS T1 JOIN employees AS T2 ON T1.id = T2.reports_to WHERE T1.first_name = [Nancy] AND T1.last_name = [Edwards] |
What is the first and last name of the employee who reports to Nancy Edwards? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT T2.first_name, T2.last_name FROM employees AS T1 JOIN employees AS T2 ON T1.id = T2.reports_to WHERE T1.first_name = [Nancy] AND T1.last_name = [Edwards] |
What is the address of employee Nancy Edwards? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT address FROM employees WHERE first_name = [Nancy] AND last_name = [Edwards] |
What is Nancy Edwards's address? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT address FROM employees WHERE first_name = [Nancy] AND last_name = [Edwards] |
Find the full name of employee who supported the most number of customers. | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 1 T1.first_name, T1.last_name FROM employees AS T1 JOIN customers AS T2 ON T1.id = T2.support_rep_id GROUP BY T1.id ORDER BY CASE WHEN COUNT_BIG(*) IS NULL THEN 1 ELSE 0 END DESC, COUNT_BIG(*) DESC |
What is the full name of the employee who has the most customers? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 1 T1.first_name, T1.last_name FROM employees AS T1 JOIN customers AS T2 ON T1.id = T2.support_rep_id GROUP BY T1.id ORDER BY CASE WHEN COUNT_BIG(*) IS NULL THEN 1 ELSE 0 END DESC, COUNT_BIG(*) DESC |
How many employees are living in Canada? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT COUNT_BIG(*) FROM employees WHERE country = [Canada] |
How many employees live in Canada? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT COUNT_BIG(*) FROM employees WHERE country = [Canada] |
What is employee Nancy Edwards's phone number? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT phone FROM employees WHERE first_name = [Nancy] AND last_name = [Edwards] |
What is the the phone number of Nancy Edwards? | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT phone FROM employees WHERE first_name = [Nancy] AND last_name = [Edwards] |
Who is the youngest employee in the company? List employee's first and last name. | -- Tables de la base de données (T-SQL) --
TABLE [artists] (
[id] NVARCHAR(MAX),
[name] NVARCHAR(MAX)
);
TABLE [albums] (
[id] INT,
[title] NVARCHAR(MAX),
[artist id] INT
);
TABLE [employees] (
[id] INT,
[last name] NVARCHAR(MAX),
[first name] NVARCHAR(MAX),
[title] NVARCHAR(MAX),
... | SELECT TOP 1 first_name, last_name FROM employees ORDER BY CASE WHEN birth_date IS NULL THEN 1 ELSE 0 END DESC, birth_date DESC |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.