Navigation Menu

Search code, repositories, users, issues, pull requests..., provide feedback.

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly.

To see all available qualifiers, see our documentation .

  • Notifications You must be signed in to change notification settings

2nd SQL assignment

Sagnik1004/SQL-Lab-Assignment-

Folders and files.

NameName
7 Commits

Repository files navigation

Sql-lab-assignment-.

We have been provided a database schema on supply chain data. Then we have been asked to write queries in a sql script file to answer various business questions.

SQL Tutorial

Sql database, sql references, sql examples, sql exercises.

You can test your SQL skills with W3Schools' Exercises.

We have gathered a variety of SQL exercises (with answers) for each SQL Chapter.

Try to solve an exercise by filling in the missing parts of a code. If you're stuck, hit the "Show Answer" button to see what you've done wrong.

Count Your Score

You will get 1 point for each correct answer. Your score and total score will always be displayed.

Start SQL Exercises

Start SQL Exercises ❯

If you don't know SQL, we suggest that you read our SQL Tutorial from scratch.

Kickstart your career

Get certified by completing the course

Get Certified

COLOR PICKER

colorpicker

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: [email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail: [email protected]

Top Tutorials

Top references, top examples, get certified.

  • ▼SQL Exercises
  • Introduction
  • Retrieve data from tables
  • Boolean and Relational Operators
  • Wildcard and Special operators
  • Aggregate Functions
  • Formatting query output
  • Query on Multiple Tables
  • FILTERING and SORTING on HR Database
  • SUBQUERIES on HR Database
  • JOINS on HR Database
  • SQL User Management
  • ▼Movie Database
  • BASIC QUERIES
  • ▼Soccer Database
  • ▼Hospital Database
  • ▼Employee Database
  • ▼AdventureWorks Database
  • ▼SQL Challenges
  • Challenges-1
  • ..More to come..

SQL Exercises, Practice, Solution

What is sql.

SQL stands for Structured Query Language and it is an ANSI standard computer language for accessing and manipulating database systems. It is used for managing data in relational database management system which stores data in the form of tables and relationship between data is also stored in the form of tables. SQL statements are used to retrieve and update data in a database.

The best way we learn anything is by practice and exercise questions. We have started this section for those (beginner to intermediate) who are familiar with SQL . Hope, these exercises help you to improve your SQL skills. Currently following sections are available, we are working hard to add more exercises. Happy Coding!

You may read our SQL tutorial before solving the following exercises.

List of SQL Exercises

  • SQL Retrieve data from tables [33 Exercises]
  • SQL Boolean and Relational operators [12 Exercises]
  • SQL Wildcard and Special operators [22 Exercises]
  • SQL Aggregate Functions [25 Exercises]
  • SQL Formatting query output [10 Exercises]
  • SQL Quering on Multiple Tables [8 Exercises]
  • FILTERING and SORTING on HR Database [38 Exercises]
  • SQL JOINS [29 Exercises]
  • SQL JOINS on HR Database [27 Exercises]
  • SQL SUBQUERIES
  • SQL SUBQUERIES [39 Exercises]
  • SQL SUBQUERIES on HR Database [55 Exercises]
  • SQL Union[9 Exercises]
  • SQL View[16 Exercises]
  • SQL User Account Management [16 Exercise]
  • Movie Database
  • BASIC queries on movie Database [10 Exercises]
  • SUBQUERIES on movie Database [16 Exercises]
  • JOINS on movie Database [24 Exercises]
  • Soccer Database
  • BASIC queries on soccer Database [29 Exercises]
  • SUBQUERIES on soccer Database [33 Exercises]
  • JOINS queries on soccer Database [61 Exercises]
  • Hospital Database
  • BASIC, SUBQUERIES, and JOINS [41 Exercises]
  • Employee Database
  • BASIC queries on employee Database [115 Exercises]
  • SUBQUERIES on employee Database [77 Exercises]
  • AdventureWorks Database:
  • AdventureWorks Database [200 Exercises]
  • SQL Challenges-1:
  • SQL Challenges-1 [77 Exercises]
  • More to come!

Structure of inventory database :

Inventory database

Structure of HR database :

Structure of movie database :

Movie database

Structure of soccer database :

Soccer database

Structure of employee database :

Employee database

Structure of hospital database :

Hospital database

Syntax diagram of SQL SELECT statement

Employee database

You may download the structure and data of the tables of database on which SQL Exercises are built.

Please note that PostgreSQL 9.4 is used and the file which you would download is generated using pg_dump

Follow us on Facebook and Twitter for latest update.

  • Weekly Trends and Language Statistics
  • SQL Cheat Sheet
  • SQL Interview Questions
  • MySQL Interview Questions
  • PL/SQL Interview Questions
  • Learn SQL and Database
  • SQL Exercises
  • SQL Concepts and Queries
  • SQL - SELECT LAST
  • SQL for Data Science
  • SQL Query Interview Questions
  • 7 Best Books for SQL
  • Nested Queries in SQL
  • Oracle Interview Experience
  • TCS NQT interview Experience
  • Shell India Interview Experience
  • DE Shaw Interview Experience
  • TCS NQT Interview Experience
  • Sapient Interview Experience | Set 4
  • TCS Ninja Interview Experience
  • Infosys InfyTQ Interview Experience
  • SAP Labs Interview Experience | Set 7

SQL Exercises : SQL Practice with Solution for Beginners and Experienced

SQL ( Structured Query Language ) is a powerful tool used for managing and manipulating relational databases. Whether we are beginners or experienced professionals, practicing SQL exercises is important for improving your skills. Regular practice helps you get better at using SQL and boosts your confidence in handling different database tasks.

So, in this free SQL exercises page, we’ll cover a series of SQL practice exercises covering a wide range of topics suitable for beginners , intermediate , and advanced SQL learners. These exercises are designed to provide hands-on experience with common SQL tasks, from basic retrieval and filtering to more advanced concepts like joins window functions , and stored procedures.

Table of Content

SQL Exercises for Practice

Sql practice exercises for beginners, sql practice exercises for intermediate, sql practice exercises for advanced, more questions for practice.

Practice SQL questions to enhance our skills in database querying and manipulation. Each question covers a different aspect of SQL , providing a comprehensive learning experience.

SQL-Practice-Questions-with-Sollutions

We have covered a wide range of topics in the sections beginner , intermediate and advanced .

  • Basic Retrieval
  • Arithmetic Operations and Comparisons:
  • Aggregation Functions
  • Group By and Having
  • Window Functions
  • Conditional Statements
  • DateTime Operations
  • Creating and Aliasing
  • Constraints
  • Stored Procedures:
  • Transactions

let’s create the table schemas and insert some sample data into them.

Create Sales table

sales_table

Create Products table

Product_Table

This hands-on approach provides a practical environment for beginners to experiment with various SQL commands, gaining confidence through real-world scenarios. By working through these exercises, newcomers can solidify their understanding of fundamental concepts like data retrieval, filtering, and manipulation, laying a strong foundation for their SQL journey.

1. Retrieve all columns from the Sales table.

sale_id product_id quantity_sold sale_date total_price
1 101 5 2024-01-01 150
2 102 3 2024-01-02 90
3 103 2 2024-01-02 60
4 104 4 2024-01-03 120
5 105 6 2024-01-03 180

Explanation: This SQL query selects all columns from the Sales table, denoted by the asterisk (*) wildcard. It retrieves every row and all associated columns from the Sales table.

2. Retrieve the product_name and unit_price from the Products table.

product_name unit_price
Laptop 500
Smartphone 300
Headphones 30
Keyboard 20
Mouse 15

Explanation:

This SQL query selects the product_name and unit_price columns from the Products table. It retrieves every row but only the specified columns, which are product_name and unit_price.

3. Retrieve the sale_id and sale_date from the Sales table.

sale_id sale_date
1 2024-01-01
2 2024-01-02
3 2024-01-02
4 2024-01-03
5 2024-01-03
This SQL query selects the sale_id and sale_date columns from the Sales table. It retrieves every row but only the specified columns, which are sale_id and sale_date.

4. Filter the Sales table to show only sales with a total_price greater than $100.

sale_id product_id quantity_sold sale_date total_price
1 101 5 2024-01-01 150
4 104 4 2024-01-03 120
5 105 6 2024-01-03 180
This SQL query selects all columns from the Sales table but only returns rows where the total_price column is greater than 100. It filters out sales with a total_price less than or equal to $100.

5. Filter the Products table to show only products in the ‘Electronics’ category.

product_id product_name category unit_price total_price
101 Laptop Electronics 500 150
102 Smartphone Electronics 300 120
103 Headphones Electronics 30 180
This SQL query selects all columns from the Products table but only returns rows where the category column equals ‘Electronics’. It filters out products that do not belong to the ‘Electronics’ category.

6. Retrieve the sale_id and total_price from the Sales table for sales made on January 3, 2024.

sale_id total_price
4 120
5 180
This SQL query selects the sale_id and total_price columns from the Sales table but only returns rows where the sale_date is equal to ‘2024-01-03’. It filters out sales made on any other date.

7. Retrieve the product_id and product_name from the Products table for products with a unit_price greater than $100.

product_id product_name
101 Laptop
102 Smartphone
This SQL query selects the product_id and product_name columns from the Products table but only returns rows where the unit_price is greater than $100. It filters out products with a unit_price less than or equal to $100.

8. Calculate the total revenue generated from all sales in the Sales table.

total_revenue
600
This SQL query calculates the total revenue generated from all sales by summing up the total_price column in the Sales table using the SUM() function.

9. Calculate the average unit_price of products in the Products table.

average_unit_price
173
This SQL query calculates the average unit_price of products by averaging the values in the unit_price column in the Products table using the AVG() function.

10. Calculate the total quantity_sold from the Sales table.

total_quantity_sold
20
This SQL query calculates the total quantity_sold by summing up the quantity_sold column in the Sales table using the SUM() function.

11. Retrieve the sale_id, product_id, and total_price from the Sales table for sales with a quantity_sold greater than 4.

sale_id product_id total_price
1 101 150
5 105 180
This SQL query selects the sale_id, product_id, and total_price columns from the Sales table but only returns rows where the quantity_sold is greater than 4.

12. Retrieve the product_name and unit_price from the Products table, ordering the results by unit_price in descending order.

This SQL query selects the product_name and unit_price columns from the Products table and orders the results by unit_price in descending order using the ORDER BY clause with the DESC keyword.

13. Retrieve the total_price of all sales, rounding the values to two decimal places.

product_name
600
This SQL query calculates the total sales revenu by summing up the total_price column in the Sales table and rounds the result to two decimal places using the ROUND() function.

14. Calculate the average total_price of sales in the Sales table.

average_total_price
120.00
This SQL query calculates the average total_price of sales by averaging the values in the total_price column in the Sales table using the AVG() function.

15. Retrieve the sale_id and sale_date from the Sales table, formatting the sale_date as ‘YYYY-MM-DD’.

sale_id formatted_date
1 2024-01-01
2 2024-01-02
3 2024-01-02
4 2024-01-03
5 2024-01-03
This SQL query selects the sale_id and sale_date columns from the Sales table and formats the sale_date using the DATE_FORMAT() function to display it in ‘YYYY-MM-DD’ format.

16. Calculate the total revenue generated from sales of products in the ‘Electronics’ category.

This SQL query calculates the total revenue generated from sales of products in the ‘Electronics’ category by joining the Sales table with the Products table on the product_id column and filtering sales for products in the ‘Electronics’ category.

17. Retrieve the product_name and unit_price from the Products table, filtering the unit_price to show only values between $20 and $600.

product_name unit_price
Laptop 500
Smartphone 300
Headphones 30
Keyboard 20
This SQL query selects the product_name and unit_price columns from the Products table but only returns rows where the unit_price falls within the range of $50 and $200 using the BETWEEN operator.

18. Retrieve the product_name and category from the Products table, ordering the results by category in ascending order.

product_name category
Laptop Electronics
Smartphone Electronics
Headphones Electronics
Keyboard Electronics
Mouse Electronics
This SQL query selects the product_name and category columns from the Products table and orders the results by category in ascending order using the ORDER BY clause with the ASC keyword.

19. Calculate the total quantity_sold of products in the ‘Electronics’ category.

This SQL query calculates the total quantity_sold of products in the ‘Electronics’ category by joining the Sales table with the Products table on the product_id column and filtering sales for products in the ‘Electronics’ category.

20. Retrieve the product_name and total_price from the Sales table, calculating the total_price as quantity_sold multiplied by unit_price.

product_name total_price
Laptop 2500
Smartphone 900
Headphones 60
Keyboard 80
Mouse 90
This SQL query retrieves the product_name from the Sales table and calculates the total_price by multiplying quantity_sold by unit_price, joining the Sales table with the Products table on the product_id column.

These exercises are designed to challenge you beyond basic queries, delving into more complex data manipulation and analysis. By tackling these problems, you’ll solidify your understanding of advanced SQL concepts like joins, subqueries, functions, and window functions, ultimately boosting your ability to work with real-world data scenarios effectively.

1. Calculate the total revenue generated from sales for each product category.

category total_revenue
Electronics 600
This query joins the Sales and Products tables on the product_id column, groups the results by product category, and calculates the total revenue for each category by summing up the total_price.

2. Find the product category with the highest average unit price.

category
Electronics
This query groups products by category, calculates the average unit price for each category, orders the results by the average unit price in descending order, and selects the top category with the highest average unit price using the LIMIT clause.

3. Identify products with total sales exceeding $500.

product_name
Headphones
Keyboard
Laptop
Mouse
Smartphone
This query joins the Sales and Products tables on the product_id column, groups the results by product name, calculates the total sales revenue for each product, and selects products with total sales exceeding 30 using the HAVING clause.

4. Count the number of sales made in each month.

month

sales_count

2024-01

5

This query formats the sale_date column to extract the month and year, groups the results by month, and counts the number of sales made in each month.

5. Determine the average quantity sold for products with a unit price greater than $100.

average_quantity_sold
4
This query joins the Sales and Products tables on the product_id column, filters products with a unit price greater than $100, and calculates the average quantity sold for those products.

6. Retrieve the product name and total sales revenue for each product.

product_name total_revenue
Headphones 60
Keyboard 120
Laptop 150
Mouse 180
Smartphone 90
This query joins the Sales and Products tables on the product_id column, groups the results by product name, and calculates the total sales revenue for each product.

7. List all sales along with the corresponding product names.

sale_id product_name
1 Laptop
2 Smartphone
3 Headphones
4 Keyboard
5 Mouse
This query joins the Sales and Products tables on the product_id column and retrieves the sale_id and product_name for each sale.

8. Retrieve the product name and total sales revenue for each product.

category category_revenue revenue_percentage
Electronics 600 100
This query will give you the top three product categories contributing to the highest percentage of total revenue generated from sales. However, if you only have one category (Electronics) as in the provided sample data, it will be the only result.

9. Rank products based on total sales revenue.

product_name total_revenue revenue_rank
Mouse 180 1
Laptop 150 2
Keyboard 120 3
Smartphone 90 4
Headphones 60 5
This query joins the Sales and Products tables on the product_id column, groups the results by product name, calculates the total sales revenue for each product, and ranks products based on total sales revenue using the RANK () window function.

10. Calculate the running total revenue for each product category.

category product_name sale_date running_total_revenue
Electronics Laptop 2024-01-01 150
Electronics Smartphone 2024-01-02 300
Electronics Headphones 2024-01-02 300
Electronics Keyboard 2024-01-03 600
Electronics Mouse 2024-01-03 600
This query joins the Sales and Products tables on the product_id column, partitions the results by product category, orders the results by sale date, and calculates the running total revenue for each product category using the SUM() window function.

11. Categorize sales as “High”, “Medium”, or “Low” based on total price (e.g., > $200 is High, $100-$200 is Medium, < $100 is Low).

sale_id sales_category
1 Medium
2 Low
3 Low
4 Medium
5 Medium
This query categorizes sales based on total price using a CASE statement. Sales with a total price greater than $200 are categorized as “High”, sales with a total price between $100 and $200 are categorized as “Medium”, and sales with a total price less than $100 are categorized as “Low”.

12. Identify sales where the quantity sold is greater than the average quantity sold.

sale_id product_id quantity_sold sale_date total_price
1 101 5 2024-01-01 150
5 105 6 2024-01-03 180
This query selects all sales where the quantity sold is greater than the average quantity sold across all sales in the Sales table.

13. Extract the month and year from the sale date and count the number of sales for each month.

month

sales_count

202401

5

14. Calculate the number of days between the current date and the sale date for each sale.

sale_id

days_since_sale

1

793

2

792

3

792

4

791

5

791

This query calculates the number of days between the current date and the sale date for each sale using the DATEDIFF function.

15. Identify sales made during weekdays versus weekends.

sale_id

day_type

1

Weekday

2

Weekday

3

Weekday

4

Weekend

5

Weekend

This query categorizes sales based on the day of the week using the DAYOFWEEK function. Sales made on Sunday (1) or Saturday (7) are categorized as “Weekend”, while sales made on other days are categorized as “Weekday”.

This section likely dives deeper into complex queries, delving into advanced features like window functions, self-joins, and intricate data manipulation techniques. By tackling these challenging exercises, users can refine their SQL skills and tackle real-world data analysis scenarios with greater confidence and efficiency.

1. Write a query to create a view named Total_Sales that displays the total sales amount for each product along with their names and categories.

product_name category total_sales_amount
Headphones Electronics 60
Keyboard Electronics 120
Laptop Electronics 150
Mouse Electronics 180
Smartphone Electronics 90
This query creates a view named Total_Sales that displays the total sales amount for each product along with their names and categories.

2. Retrieve the product details (name, category, unit price) for products that have a quantity sold greater than the average quantity sold across all products.

product_name category unit_price
Laptop Electronics 500
Mouse Electronics 15
This query retrieves the product details (name, category, unit price) for products that have a quantity sold greater than the average quantity sold across all products.

3. Explain the significance of indexing in SQL databases and provide an example scenario where indexing could significantly improve query performance in the given schema.

sale_id product_id quantity_sold sale_date total_price
4 104 4 2024-01-03 120
5 105 6 2024-01-03 180
With an index on the sale_date column, the database can quickly locate the rows that match the specified date without scanning the entire table. The index allows for efficient lookup of rows based on the sale_date value, resulting in improved query performance.

4. Add a foreign key constraint to the Sales table that references the product_id column in the Products table.

This query adds a foreign key constraint to the Sales table that references the product_id column in the Products table, ensuring referential integrity between the two tables.

5. Create a view named Top_Products that lists the top 3 products based on the total quantity sold.

product_name total_quantity_sold
Mouse 6
Laptop 5
Keyboard 4
This query creates a view named Top_Products that lists the top 3 products based on the total quantity sold.

6. Implement a transaction that deducts the quantity sold from the Products table when a sale is made in the Sales table, ensuring that both operations are either committed or rolled back together.

The quantity in stock for product with product_id 101 should be updated to 5.The transaction should be committed successfully.

7. Create a query that lists the product names along with their corresponding sales count.

product_name sales_count
Headphones 1
Keyboard 1
Laptop 1
Mouse 1
Smartphone 1
This query selects the product names from the Products table and counts the number of sales (using the COUNT() function) for each product by joining the Sales table on the product_id. The results are grouped by product name using the GROUP BY clause.

8. Write a query to find all sales where the total price is greater than the average total price of all sales.

The subquery (SELECT AVG(total_price) FROM Sales) calculates the average total price of all sales. The main query selects all columns from the Sales table where the total price is greater than the average total price obtained from the subquery.

9. Analyze the performance implications of indexing the sale_date column in the Sales table, considering the types of queries commonly executed against this column.

sale_id product_id quantity_sold sale_date total_price
1 101 5 2024-01-01 150
By comparing the execution plans and analysis results of these queries, we can evaluate the performance implications of indexing the sale_date column. We’ll be able to observe differences in factors such as the query execution time, the type of scan used (sequential scan vs. index scan), and any additional costs associated with using the index.

10. Add a check constraint to the quantity_sold column in the Sales table to ensure that the quantity sold is always greater than zero.

sale_id

product_id

quantity_sold

sale_date

total_price

1

101

5

2024-01-01

150.00

2

102

3

2024-01-02

90.00

3

103

2

2024-01-02

60.00

4

104

4

2024-01-03

120.00

5

105

6

2024-01-03

180.00

All rows in the Sales table meet the condition of the check constraint, as each quantity_sold value is greater than zero.

11. Create a view named Product_Sales_Info that displays product details along with the total number of sales made for each product.

product_id product_name category unit_price total_sales
101 Laptop Electronics 500 1
102 Smartphone Electronics 300 1
103 Headphones Electronics 30 1
104 Keyboard Electronics 20 1
105 Mouse Electronics 15 1
This view provides a concise and organized way to view product details alongside their respective sales information, facilitating analysis and reporting tasks.

12. Develop a stored procedure named Update_Unit_Price that updates the unit price of a product in the Products table based on the provided product_id.

The above SQL code creates a stored procedure named Update_Unit_Price. This stored procedure takes two parameters: p_product_id (the product ID for which the unit price needs to be updated) and p_new_price (the new unit price to set).

13. Implement a transaction that inserts a new product into the Products table and then adds a corresponding sale record into the Sales table, ensuring that both operations are either fully completed or fully rolled back.

product_id

product_name

category

unit_price

101

Laptop

Electronics

550.00

102

Smartphone

Electronics

300.00

103

Headphones

Electronics

30.00

104

Keyboard

Electronics

20.00

105

Mouse

Electronics

15.00

This will update the unit price of the product with product_id 101 to 550.00 in the Products table.

14. Write a query that calculates the total revenue generated from each category of products for the year 2024.

category

total_revenue

Electronics

600.00

When you execute this query, you will get the total revenue generated from each category of products for the year 2024.

If you’re looking to sharpen your SQL skills and gain more confidence in querying database s, consider delving into these articles. They’re packed with query-based SQL questions designed to enhance your understanding and proficiency in SQL .

By practicing with these exercises, you’ll not only improve your SQL abilities but also boost your confidence in tackling various database-related tasks. The Questions are as follows:

  • How to Insert a Value that Contains an Apostrophe in SQL?
  • How to Select Row With Max Value in SQL?
  • How to Efficiently Convert Rows to Columns in SQL?
  • How To Use Nested Select Queries in SQL
  • How to Select Row With Max Value on a Column in SQL?
  • How to Specify Condition in Count() in SQL?
  • How to Find the Maximum of Multiple Columns in SQL?
  • How to Update Top 100 Records in SQL?
  • How to Select the Last Records in a One-To-Many Relationship Using SQL Join
  • How to Join First Row in SQL?
  • How to Insert Row If Not Exists in SQL?
  • How to Use GROUP BY to Concatenate Strings in SQL?
  • How Inner Join works in LINQ to SQL
  • How to Get the Identity of an Inserted Row in SQL
  • How to Declare a Variable in SQL?

Mastering SQL requires consistent practice and hands-on experience. By working through these SQL practice exercises , you’ll strengthen your skills and gain confidence in querying relational databases.

Whether you’re just starting or looking to refine your expertise, these exercises provide valuable opportunities to hone your SQL abilities. Keep practicing , and you’ll be well-equipped to tackle real-world data challenges with SQL.

Please Login to comment...

Similar reads, improve your coding skills with practice.

 alt=

What kind of Experience do you want to share?

10 Beginner SQL Practice Exercises With Solutions

Author's photo

  • online practice
  • sql practice

Table of Contents

The Dataset

Exercise 1: selecting all columns from a table, exercise 2: selecting a few columns from a table, exercise 3: selecting a few columns and filtering numeric data in where, exercise 4: selecting a few columns and filtering text data in where, exercise 5: selecting a few columns and filtering data using two conditions in where, exercise 6: filtering data using where and sorting the output, exercise 7: grouping data by one column, exercise 8: grouping data by multiple columns, exercise 9: filtering data after grouping, exercise 10: selecting columns from two tables, that was fun now, time to do sql practice on your own.

Solve these ten SQL practice problems and test where you stand with your SQL knowledge!

This article is all about SQL practice. It’s the best way to learn SQL. We show you ten SQL practice exercises where you need to apply essential SQL concepts. If you’re an SQL rookie, no need to worry – these examples are for beginners.

Use them as a practice or a way to learn new SQL concepts. For more theoretical background and (even more!) exercises, there’s our interactive SQL Basics course. It teaches you how to select data from one or more tables, aggregate and group data, write subqueries, and use set operations. The course comprises 129 interactive exercises so there is no lack of opportunities for SQL practice, especially if you add some of the 12 ways of learning SQL online to it.

Speaking of practice, let’s start with our exercises!

The question is always where to find data for practicing SQL. We’ll use our dataset for all exercises. No need to limit yourself to this, though – you can find other free online datasets for practicing SQL .

Our dataset consists of two tables.

The table distribution_companies lists movie distribution companies with the following columns:

  • id – The ID of the distribution company. This is the primary key of the table.
  • company_name – The name of the distribution company.

The table is shown below.

idcompany_name
1Columbia Pictures
2Paramount Pictures
3Warner Bros. Pictures
4United Artists
5Universal Pictures
6New Line Cinema
7Miramax Films
8Produzioni Europee Associate
9Buena Vista
10StudioCanal

The second table is movies . These are the columns:

  • id – The ID of the movie. This is the primary key of the table.
  • movie_title – The movie title.
  • imdb_rating – The movie rating on IMDb.
  • year_released – The year the movie was released.
  • budget – The budget for the movie in millions of dollars.
  • box_office – The earnings of the movie in millions of dollars.
  • distribution_company_id – The ID of the distribution company, referencing the table distribution_companies (foreign key).
  • language – The language(s) spoken in the movie.
idmovie_titleimdb_ratingyear_releasedbudgetbox_officedistribution_company_idlanguage
1The Shawshank Redemption9.2199425.0073.301English
2The Godfather9.219727.20291.002English
3The Dark Knight9.02008185.001,006.003English
4The Godfather Part II9.0197413.0093.002English, Sicilian
512 Angry Men9.019570.342.004English
6Schindler's List8.9199322.00322.205English, German, Yiddish
7The Lord of the Rings: The Return of the King8.9200394.001,146.006English
8Pulp Fiction8.819948.50213.907English
9The Lord of the Rings: The Fellowship of the Ring8.8200193.00898.206English
10The Good, the Bad and the Ugly8.819661.2038.908English, Italian, Spanish

Exercise: Select all data from the table distribution_companies .

Solution explanation: Select the data using the SELECT statement. To select all the columns, use an asterisk ( * ). The table from which the data is selected is specified in the FROM clause.

Solution output:

Exercise: For each movie, select the movie title, the IMDb rating, and the year the movie was released.

Solution explanation: List all the columns needed ( movie_title , imdb_rating , and year_released ) in the SELECT statement, separated by the comma. Reference the table movies in the FROM clause.

movie_titleimdb_ratingyear_released
The Shawshank Redemption9.21994
The Godfather9.21972
The Dark Knight9.02008
The Godfather Part II9.01974
12 Angry Men9.01957
Schindler's List8.91993
The Lord of the Rings: The Return of the King8.92003
Pulp Fiction8.81994
The Lord of the Rings: The Fellowship of the Ring8.82001
The Good, the Bad and the Ugly8.81966

Exercise: Select the columns movie_title and box_office from the table movies . Show only movies with earnings above $300 million.

Solution explanation: List the columns in SELECT and reference the table in FROM . Use a WHERE clause to filter the data – write the column box_office and use the ‘greater than’ operator ( > ) to show only values above $300 million.

movie_titlebox_office
The Dark Knight1,006.00
Schindler's List322.20
The Lord of the Rings: The Return of the King1,146.00
The Lord of the Rings: The Fellowship of the Ring898.20

Exercise: Select the columns movie_title , imdb_rating , and year_released from the table movies . Show movies that have the word ‘Godfather’ in the title.

Solution explanation: List the columns in SELECT and reference the table in the FROM clause. Use a WHERE clause to filter the data. After writing the column name, use the LIKE logical operator to look for ‘Godfather’ in the movie title, written in single quotes. To find the word anywhere in the movie title, place the wildcard character ( % ) before and after the word.

movie_titleimdb_ratingyear_released
The Godfather9.21972
The Godfather Part II9.01974

Exercise: Select the columns movie_title , imdb_rating , and year_released from the table movies . Show movies that were released before 2001 and had a rating above 9.

Solution explanation: List the columns in SELECT and reference the table in FROM . Set the first condition that the year released is before 2001 using the ‘less than’ ( < ) operator. To add another condition, use the AND logical operator. Use the same logic as the first condition, this time using the ‘greater than’ operator with the column imdb_rating .

movie_titleimdb_ratingyear_released
The Shawshank Redemption9.21994
The Godfather9.21972

Exercise: Select the columns movie_title , imdb_rating , and year_released from the table movies . Show movies released after 1991. Sort the output by the year released in ascending order.

Solution explanation: List the columns in SELECT and reference the table in FROM . Filter the data with WHERE by applying the ‘greater than’ operator to the column year_released . To sort the data, use an ORDER BY clause and write the column name by which you wish to sort. The type of sorting is specified by writing ASC (ascending) or DESC (descending). If the type is omitted, the output is sorted in ascending order by default.

movie_titleimdb_ratingyear_released
Schindler's List8.91993
The Shawshank Redemption9.21994
Pulp Fiction8.81994
The Lord of the Rings: The Fellowship of the Ring8.82001
The Lord of the Rings: The Return of the King8.92003
The Dark Knight9.02008

Exercise: Show the count of movies per each language category.

Solution explanation: Select the column language from the table movies . To count the number of movies, use the aggregate function COUNT() . Use the asterisk ( * ) to count the rows, which equals the count of movies. To give this column a name, use the AS keyword followed by the desired name. To show the count by language, you need to group the data by it, so write the column language in the GROUP BY clause.

languagenumber_of_movies
English7
English, German, Yiddish1
English, Sicilian1
English, Italian, Spanish1

Exercise: Show the count of movies by year released and language. Sort results by the release date in ascending order.

Solution explanation: List the columns year_released and language from the table movies in SELECT . Use COUNT(*) to count the number of movies and give this column a name using the AS keyword. Specify the columns by which you want to group in the GROUP BY clause. Separate each column name with a comma. Sort the output using ORDER BY with the column year_released and the ASC keyword.

year_releasedlanguagenumber_of_movies
1957English1
1966English, Italian, Spanish1
1972English1
1974English, Sicilian1
1993English, German, Yiddish1
1994English2
2001English1
2003English1
2008English1

Exercise: Show the languages spoken and the average movie budget by language category. Show only the languages with an average budget above $50 million.

Solution explanation: Select the column language from the table movies . To compute the average budget, use the aggregate function AVG() with the column budget in parentheses. Name the column in the output by using the AS keyword. Group the data by rating using GROUP BY . To filter the data after grouping, use a HAVING clause. In it, use the same AVG() construct as in SELECT and set the values to be above 50 using the ‘greater than’ operator.

languagemovie_budget
English59.01

Exercise: Show movie titles from the table movies , each with the name of its distribution company.

Solution explanation: List the columns movie_title and company_name in SELECT . In the FROM clause, reference the table distribution_companies . Give it an alias dc to shorten its name for use later. The AS keyword is omitted here; you may use it if you wish. To access the data from the other table, use JOIN (it may also be written as INNER JOIN ) and write the table name after it. Give this table an alias also. The join used here is an inner type of join; it returns only the rows that match the joining condition specified in the ON clause. The tables are joined where the column id from the table distribution_companies is equal to the column distribution_company_id from the table movies . To specify which column is from which table, use the corresponding alias of each table.

movie_titlecompany_name
The Shawshank RedemptionColumbia Pictures
The Godfather Part IIParamount Pictures
The GodfatherParamount Pictures
The Dark KnightWarner Bros. Pictures
12 Angry MenUnited Artists
Schindler's ListUniversal Pictures
The Lord of the Rings: The Fellowship of the RingNew Line Cinema
The Lord of the Rings: The Return of the KingNew Line Cinema
Pulp FictionMiramax Films
The Good, the Bad and the UglyProduzioni Europee Associate

These ten SQL practice exercises give you a taste of what practicing SQL looks like. Whether you are at the beginner, intermediate, or advanced level, it’s the same. What changes is the complexity of the problems you solve and of the code you write.

Look for more challenges in the SQL Basics course and the Monthly SQL Practice track. Both are excellent for your SQL practice online. This is true, especially if you do not have an opportunity to use SQL on a daily basis in your job.

So, don’t try to test how long it takes to forget what you once knew in SQL! Use every opportunity to solve as many SQL practice problems as possible.

You may also like

sql lab assignment

How Do You Write a SELECT Statement in SQL?

sql lab assignment

What Is a Foreign Key in SQL?

sql lab assignment

Enumerate and Explain All the Basic Elements of an SQL Query

In this Lab, you will get practice with more advanced SQL queries, particularly with multi-table queries (joins). Join queries tend to be more tricky to design and write, but are one of the most powerful features of relational databases. This lab will particularly be useful for practicing JOINs for the Final Exam.

We will use the CSE 154 Query Tester for this lab. There are other exercises suggested for working on your own Cloud9 databases if you finish early, for work on your final creative project and/or more exam practice.

Multi-table Query Review

When you need to return information from more than one table in a database, you can join multiple tables in a single query by specifying criteria to join on (e.g. all actor names in the actors table for which the actor starred a role in the roles table, based on matching the actor's id with the role's actor_id column).

Multi-table queries are powerful features of SQL, but figuring out the optimal way to join multiple tables for one query takes plenty of practice.

Template of a Multi-table Query (Join)

SQL (template)

SQL (example with WHERE Join)

SQL (equivalent example with JOIN keyword)

Designing a Query

Figure out the proper SQL queries in the following way:

  • Which table(s) contain the critical data? ( FROM )
  • Which columns to I need in the result set? ( SELECT )
  • How are tables connected ( JOIN and/or WHERE ) and values filtered ( WHERE )?
  • Do I need to return only DISTINCT records?
  • Do I care about the order of records returned? If so, which columns do I need to sort by and in what precedence?

Part I: World Database

world database schema

Warm-up Query: Countries in Asia

List all the full names, population, and gnp of all countries in Asia, ordered in descending order by gnp, breaking ties ordering by population in ascending order. Expected results:

English-Speaking Countries

List the full names of all countries where English is spoken as an official language. Do this as a single multi-table query. Expected results:

Languages in France

List all of the languages that are spoken in France, as well as the expected number of speakers for that language (population * percentage / 100.0). Do this as a single multi-table query. Do not hard code the country code into your query. Expected results:

Cities in China

List all of the cities in China, whose population is more than 0.2% of China's population. The results should include the name of the city, the district, the population, and the percentage of the city's population based on the total population of China. Organize results by percentage where the city with the highest population ratio comes first in the result. Do this as a single query. Do not hard code China's country code. Expected results:

High Population

List the full names of all countries that contain at least 2 cities of at least 5,000,000 people. Do this as a single multi-table query. Expected results:

Part II: Movie (IMDB-Small) Database

movie database schema

Roles in Pi

Show all roles played in the movie named Pi. To achieve this, join the movies table with the roles table and filter out all records except those in Pi. You shouldn't need to know the movie ID of Pi ahead of time to do the query.

Actors in Pi

Show the first/last names of all actors who appeared in Pi, along with their roles. You will need to join all three tables.

Actors and Genres

List all roles in a Horror or Sci-Fi movie with the first and last name of the actor who played the role, as well as the movie name. Order the results by last name alphabetically, breaking ties by first name alphabetically, further breaking ties by movie name alphabetically.

Part III: Student (Small) Database

simpsons database schema

CSE 143 Grades

List all of the grades given in the course Computer Science 143. Do this as a single query and do not hard-code 143's ID number in the query. Expected results:

CSE 143 Grades and Names

Modify your previous query to list the names and grades of all students that took Computer Science 143 and got a B- or better. Do this as a single query and do not hard-code 143's ID number in the query. Expected results:

Popular Classes

List the names of all courses that have been taken by 2 or more students. Do this as a single query and do not hard-code any ID numbers in the query. Don't show duplicates. Expected results:

More Practice

If you finish early, here are a few other suggestions to practice multi-table queries:

  • Practice using multi-table queries with the Full Stack Café example, adding Order and Customer tables with your Menu table. Whatkind of join queries would be helpful to include so that you can list all of the orders made by a customer? How about all customers who have ordered Espresso? Or al orders which have only a drink?
  • Integrate a database with multiple tables for your creative project if you haven't already. This is a really great thing to demonstrate you have experience with when applying for software development internships and jobs!
  • There are more join queries using this tutorial , as well as other advanced SQL topics and database updating (which you are working with on HW7).

Assignment 1 « SQL »

Due: 11:59pm 02/11/2021 et.

SQL Joke

Getting the Stencil

You can click here to get the stencil code for Homework 1. Reference this guide for more information about Github and Github Classroom.

The data is located in the data folder. To ensure compatibility with the autograder, you should not modify the stencil unless instructed otherwise. For this assignment, please write each of your queries to its corresponding SQL file. Failing to do so may hinder with the autograder and result in a low grade.

Virtual Environment

1. linux/osx.

You need to set up a virtual environment to run Python assignments, if you want to work on your local machine.

Our Gradescope Autograder, virtual environment guide and create_venv.sh script in your stencil code runs on Python 3.7 . You might run into strange issues setting up the virtual environment / working on future assignments if you don't have the right version of Python. Please refer to this guide for instructions to check whether you have the right Python version and how to install the correct one if you do not.

You can run ./create_venv.sh (or bash create_venv.sh ) from your assignment directory to create the virtual environment. Run chmod 775 create_venv.sh if you get a permission denied error.

If nothing is printed out in your terminal besides the message "created cs1951a environment" , congratulations! You have successfully installed the virtual environment for the course on your machine! If any error message is printed out, please utilize TA Hours / Piazza as a resource to resolve the issue(s).

From now on, whenever you want to activate your virtual environment for our assignments, you can simply type the following in your terminal:

  • Working locally : cs1951a_venv (or source ~/cs1951a_venv/bin/activate ).
  • Working on a department machine through ssh : source /course/cs1951a/venv/bin/activate

You can refer to this guide for more information about installing our course's virtual environment. If you have successfully executed our create_venv.sh script above and have the right Python version, you should not worry about reading in-depth into this resource.

If you use a Windows machine, as there are different ways students use Terminal/File Transfer to complete assignments, we unfortunately do not have a robust, uniform script/guide to install a virtual environment locally on Windows machines.

We strongly recommend running your assignment on the department machine. Git is installed on the department machines, so you should also be able to git clone your assignments onto the department machine.

The recommended workflow is to work on your assignment locally, and either (1) use version control, or (2) use SCP/PuTTY to transfer your files to the department machine. To run your assignments on the department machine, make sure to enable the course virtual environment (using source /course/cs1951a/venv/bin/activate ) before running any Python code! Refer to this resource for more support regarding file transfer, and this with respect to version control.

If you have successfully installed a Python3.7 Virtual Environment on your machine in the past: We have included the requirements.txt dependencies file on the course website ( here ). If it is helpful, we also have a virtual environment setup guide here .

If you are working locally, you can check if SQLite is installed already by running sqlite3 -version in your terminal. You can refer to this guide to install SQLite on your machine. SQLite is installed on all department machines. It can be accessed from the command line using sqlite3 .

Running sqlite3 somedb.db from your terminal will launch an environment that will allow you to type your SQL queries directly into the terminal. You can exit this environment by pushing Ctrl+D or by typing .exit and pressing enter.

As a more explicit example, to open a sql environment where you can query the movies.db database, you can type:

$ sqlite3 movies.db

To execute a SQL statement that you have saved in a solution file, you can run the following command:

For more information on using SQLite from the command line, see http://www.sqlite.org/sqlite.html . Additionally, we have provided very helpful hints for most of the problems; you should be able to use these as a starting point if you get stuck before looking up additional information online.

Some useful tools you can use to view the content in a database: SQLite Viewer and SQLTools + SQLite packages (if you are developing on VS Code ).

Part 1: Starting Off!

This part of the assignment builds off the exercises you completed in the lab. If you have not yet completed the lab, please do so before starting this assignment. There are some really useful hints and examples you can borrow from the lab for this assignment. The database and schema are described again below, but are the same from the lab.

We have provided a database named people.db with the name, age, ID, and occupation of some Brown students and alumni. Here is the schema:

In the people_friends table, each ( ID1 , ID2 ) pair indicates that the particular person with ID1 is friends with the person with ID2 (and vice versa). The friendship is mutual, and if ( ID1 , ID2 ) is in the table, it is guaranteed that ( ID2 , ID1 ) exists in the table.

In the people_likes table, each ( ID1 , ID2 ) pair indicates that the student or alumni with ID1 likes the person with ID2 . The ( ID1 , ID2 ) pair in the table does not guarantee that the ( ID2 , ID1 ) pair also exists in the table.

Your job is to write SQL queries for the data being requested:

Hint: Use a LEFT JOIN ! The following website is quite useful: http://blog.codinghorror.com/a-visual-explanation-of-sql-joins/

Hint: The LIMIT statement will come in handy!

Hint: You'll need to take a look at the HAVING function.

  • (4 points) Write a SQL statement that returns the distinct name and age of all people who are liked by anyone younger than them. Results should be ordered by name (A-Z). Save the query to part1_problem4.sql .
  • (4 points) Write a SQL statement to find pairs (A, B) such that person A likes person B, but A is not friends with B. The query should return 4 columns: ID of person 1, name of person 1, ID of person 2 and name of person 2. Results should be ordered by ID1 (ascending), then ID2 (ascending). Save the query to part1_problem5.sql

Time to join stuff!

SQL Joke

Part 2: Getting Harder!

For this part of the assignment, you will be using the TMDB Movie Dataset, which has been exported to the movies.db database. The database schema is as follows:

We encourage you to use the WITH operator, which lets you divide your query into separate queries. As an example, we can define a subquery and use it in another query as follows (there is also an example in the lab!):

You can add days to a particular day by using the date function. For example, in order to add 3 days to to '2012-07-16', you can use date('2012-07-16', '+3 days')

Hint: The UNION statement should come in handy.

  • (10 points) Write a SQL query to count the number of movies that start with "The", end with a "2" or contain the word "shark". Your query should be case insensitive and return one column with one entry. You should return a single value.

Hint: You may want to look into CASE statements and the LIKE operator. (Lab!)

  • (10 points) Write a SQL query to select the original_title of all movies and a column where there is a 1 if there exists another movie that has the same vote average and the same runtime as that movie, and a 0 otherwise. Results should be ordered by original_title (A-Z).

Hint: Look into the BETWEEN statement and how it can be used in a join.

Another Hint: Do not modify the current database by using UPDATE . Take a look at the CASE operation example from the lab.

  • (10 points) Write a SQL query that finds the original_title , release_date and revenue of all the movies whose revenue exceeded the average revenue of all the movies released on the same day (including itself). Results should be ordered by release_date (ascending), and then revenue (descending).

(10 points) Write a SQL query that, for each original_language that has more than 2 movies , finds the number of movies that were reviewed as 'poor' and the number of movies that were reviewed as 'good'.

Like in the 4th question, you will need to look at the scores table to see what the review categories are and use the vote_average field of a movie to determine which review category it falls under. Your query should return 3 columns ( original_language , num_poor which is the number of 'poor' movies for that language, and num_good which should be the number of 'good' movies for the language). Your results should be ordered by number of 'good' movies (descending) and then number of 'poor' movies (ascending). Remember to only include languages that have more than 2 movies!

Hint: Refer to the examples from the lab!

Part 3: Optimization

We have provided you with the athletes.db database, although querying it is not necessary at all. The schema is as follows:

For the query below , explain why the given query might not be the most efficient way to accomplish the task. Write out an optimized version of the query in writeup.txt . Explain what steps you took to optimize it and why your version would be more efficient.

(6 points) The SQL query to optimize is as follows:

(4 points) Consider two tables. Table A is very long with 1 billion rows and 5 columns. Table B is very wide with 1000 rows and 10,000 columns. If we were to join the two tables and want to make sure the join is performant, how should we best filter the tables? Assume that we can select from each table and then join the results. Specifically, state the table in which we should use WHERE heavily and the table in which we should be careful about what values we use in our SELECT.

Part 4: Datasets & Society

  • Demonstrate how the design of database schemas can embed social values and/or inflict harm
  • Highlight a proposed process for dataset creators that raises a wide range of social and ethical concerns
  • Reflect on the possibilities and limitations of this process
  • Read When Binary Code Won’t Accommodate Nonbinary People
  • Read Section 1 (Introduction and Objectives), Section 3 (Questions and Workflow), and Section 4 (Impact and Challenges) of the paper Datasheets for Datasets .
  • Answer the questions below in writeup.txt . Each response should be thoughtful, provide justification for your claims, and be concise but complete. See the response guide for more guidance.
  • Name one context for which it would be beneficial to add a column to people_likes that measures the strength of the feelings or add a column to people_friends that measures the strength of the friendship. Name one context for which those additions could be harmful.
  • For example: The questions “What mechanisms or procedures were used to collect the data? How were these mechanisms or procedures validated?” could have helped identify and prevent errors in automatic COVID-19 data collection in England. Public Health England used an outdated Excel file format in their automatic process to pull COVID-19 data together, leading nearly 16,000 coronavirus cases to go unreported. If the dataset creator had thought of procedures to validate this process ahead of time, they could have identified the loss of data earlier and prevented the threat to public health efforts. (Source: https://www.bbc.com/news/technology-54423988 )
  • (4 points) Identify a social, ethical, or political issue that is raised in “When Binary Code Won’t Accomodate Nonbinary People” but is not addressed by the proposed datasheet system. Propose a modification or addition to the datasheet system that helps address this issue. Your proposal could involve new sections, questions, external infrastructure, incentives, and more! Explain how your proposal would help address the issue you identified.

Additional Information

  • Google’s star AI ethics researcher, one of a few Black women in the field, says she was fired for a critical email
  • Timnit Gebru’s Exit From Google Exposes a Crisis in AI
  • Ousted Black Google Researcher: 'They Wanted To Have My Presence, But Not Me Exactly'

After finishing the assignment (and any assignment in the future), run python3 zip_assignment.py in the command line from your assignment directory, and fix any issues brought up by the script.

After the script has been run successfully, you should find the file sql-submission-1951A.zip in your assignment directory. Please submit this zip file on Gradescope under the respective assignment.

(If you have not signed up for Gradescope already, please refer to this guide .)

Made with ♥ by Jens and Esteban, updated for Spring 2021 by Yuchen, Sunny and Nazem.

The socially responsible computing component was designed by Lena and Gaurav.

Movie Database from: https://www.kaggle.com/tmdb/tmdb-movie-metadata

Computational Social Science: Theory & Application

3.13 lab: working with a sql database, 3.13.1 creating an sql database.

  • COVID: Problem.. screen has not enough surface to watch and to really work in parallel in our lab…

For this first part of the class, we’ll be working with a SQLite database, which is self-contained in a file within our hard drive, without any need to set up a server. The dataset we will work with comes from Twitter (tweets by politicians). It contains various pieces of information such as the twitter handle screen_name , and id for the person user_id_str and for the tweet id_str , the single tweets stores in text , the time when the tweet was created created_at etc.

I will send you a link (by email) to a folder where your can download two datafiles data_tweets_en.csv and data_tweets_de.csv . For simplicity we’ll work with small datafiles here. Make sure to store them in your working directory. We’ll start by connecting to the database and adding the first table, with information on the tweets.

Note that we have used dbWriteTable to add the data frame to our database, and then check that it all worked with dbListFields and dbGetQuery . As we will see in a second, this second function is what we will use to query the database, and it will always return a table.

We now switch to the second dataset data_tweets_de.csv and also create a table in our database for this dataset simply repeating the steps above.

The two files are sufficiently small to load them into our memory. However, imagine together they would exceed your RAM (e.g. > 8 GB). Then we would need to add them to the database in a sequence, one by one (in sizes that we can still open in R).

Below we sequentially add our two datafiles (we have them still in memory) to a single table in the database (if you have many files use a loop!).

3.13.2 Querying an SQL database

Now that we have our tables in the database, let’s see how we can query them. First we connect using dbConnect and then we type our query with dbGetQuery . Generally, we will write the query clauses in capital letters and the column names in lowercase.

This is the list of query clauses that we will use below (you always need SELECT and FROM ):

SELECT : determines which columns to include in the query’s result set

FROM : identifies the tables from which to draw data and how tables should be joined

LIMIT : in combination with SELECT, limits the number of records returned

WHERE : filter out unwanted data

GROUP BY : groups rows together by common column values

ORDER BY : sorts the rows in the final result set by one or more columns

Let’s start with some examples of SELECT :

Now some examples of how we can use WHERE to subset the database based on values of specific columns:

Sometimes we might just want to pull out one variable to calculate its mean:

Q: Why is it useful to draw a random sample as opposed to analyzing the full population? (Tip: Statistical inference)

Very useful for us – GROUP BY allows us to aggregate results based on values of a specific variables. We will come back to this later, so don’t worry about it for now.

And we can then order the results using ORDER BY . The default is alphabetical order for the first column, but we can change that:

3.13.3 Querying multiple SQL tables

Now’s where we get to see the magic of SQL. It makes it really easy to combine multiple SQL tables using JOIN . We just select columns from different tables and then specify what key should be used to match them using ON .

The example belows shows an inner join , but there are other types (left vs right outer joins, cross joins…) that we will not cover in this workshop.

Once we know how to merge tables, we can use columns from both tables. For example, let’s say we want to find the tweets that got the highest retweet_count (beware we have retweets included here). Here’s how we would do it:

3.13.4 Grouping and aggregating

SQL makes it really easy to compute aggregate statistics of one column based on values of a different column, with a series of built-in functions (COUNT, AVG, MAX, MIN…). Let’s now see a few examples of this type of queries:

Combining everything we’ve learned, we can for example count the total number of posts by screen_name, or by screen_name and retweet_count.

Here’s another example. Let’s say we want to find out which user (screen_name) wrote the most tweets (and add the sum of favorites given by other users). How would we do this?

There are other functions besides just COUNT . We can also compute averages, the maximum and minimum of a column… We can also use functions like SUBSTR to extract parts of a character string.

SQL Server Training, SQL Server Video Courses, SQL Server Learning Kits, Online Classes, Hands On Labs Logo

SQLMaestros Hands-On-Labs

Welcome to sqlmaestros hands-on-labs.

SQLMaestros Hands-On-Labs are packaged in multiple volumes based on roles (DBA, DEV & BIA). Each lab document consists of multiple exercises and each exercise consists of multiple tasks. Apart from step-by-step instructions, the HOL document contains images, explanations, observations, notes, tips & tricks to ensure a great learning experience. With each lab, you can practice a specific concept step-by-step. SQLMaestros Hands-On-Labs enables the practical way of learning. With our HOL documents you will get hands-on with hundreds of topics in SQL Server & Microsoft Data Platform. The best way to learn is to do-it-yourself, so please stop being lazy and start practicing.

Free Hands-On-Labs

Lab TitleDownload
SSIS Data Flow Transformations – Part 1
SQL Server Extended Events Basics
SQL Server Temporary Tables and Table Variables

Purchase Option 1: Buy volumes (see below table) Purchase Option 2: Buy selected labs (see end of table)

Looking for Corporate Subscription (for your team members/for a group of people)? Click Here .

VolumeLabs IncludedPrice
(IPT Volume 1)

Total Labs: 11

Regular Price:
Offer Price:

   

By purchasing this volume, you get to download the mentioned labs and associated scripts. You get to keep them forever.
(IPT Volume 2)

Total Labs: 11

Regular Price:
Offer Price:

   

By purchasing this volume, you get to download the mentioned labs and associated scripts. You get to keep them forever.
(IPT Volume 3)

Total Labs: 11

Regular Price:
Offer Price:

   

By purchasing this volume, you get to download the mentioned labs and associated scripts. You get to keep them forever.

Total Labs: 11

Regular Price:
Offer Price:

   

By purchasing this volume, you get to download the mentioned labs and associated scripts. You get to keep them forever.

Total Labs: 11

Regular Price:
Offer Price:

   

By purchasing this volume, you get to download the mentioned labs and associated scripts. You get to keep them forever.

Total Labs: 11

Regular Price:
Offer Price:

   

By purchasing this volume, you get to download the mentioned labs and associated scripts. You get to keep them forever.

Total Labs: 10

Regular Price:
Offer Price:

   

By purchasing this volume, you get to download the mentioned labs and associated scripts. You get to keep them forever.

Total Labs: 11

Regular Price:
Offer Price:

   

By purchasing this volume, you get to download the mentioned labs and associated scripts. You get to keep them forever.

Total Labs: 11

Regular Price:
Offer Price:

   

By purchasing this volume, you get to download the mentioned labs and associated scripts. You get to keep them forever.

Total Labs: 10

Regular Price:
Offer Price:

   

By purchasing this volume, you get to download the mentioned labs and associated scripts. You get to keep them forever.

Total Labs: 10

Regular Price:
Offer Price:

   

By purchasing this volume, you get to download the mentioned labs and associated scripts. You get to keep them forever.

Total Labs: 10

Regular Price:
Offer Price:

   

By purchasing this volume, you get to download the mentioned labs and associated scripts. You get to keep them forever.

Total Labs: 10

Regular Price:
Offer Price:

   

By purchasing this volume, you get to download the mentioned labs and associated scripts. You get to keep them forever.

Total Labs: 10

Regular Price:
Offer Price:

   

By purchasing this volume, you get to download the mentioned labs and associated scripts. You get to keep them forever.

Total Labs: 10

Regular Price:
Offer Price:

   

By purchasing this volume, you get to download the mentioned labs and associated scripts. You get to keep them forever.

Total Labs: 9

Regular Price:
Offer Price:

   

By purchasing this volume, you get to download the mentioned labs and associated scripts. You get to keep them forever.

Total Labs: 9

Regular Price:
Offer Price:

   

By purchasing this volume, you get to download the mentioned labs and associated scripts. You get to keep them forever.

Total Labs: 9

Regular Price:
Offer Price:

    



By purchasing this volume, you get to download the mentioned labs and associated scripts. You get to keep them forever.

Total Labs: 8

Regular Price:
Offer Price:

    



By purchasing this volume, you get to download the mentioned labs and associated scripts. You get to keep them forever.
Do you just need a few selected labs instead of a whole volume? No worries. You can purchase a single lab @ USD 4 (special offer). Buy as many as you want, you can choose depending on your need.

Regular Price: Offer Price:

Lab TitleCategoriesBuy Now
Auditing in SQL ServerAdministration, SQL Server
Backup and Restore Enhancements in SQL Server 2014Administration, SQL Server 2014
Concurrency Problems in SQL ServerAdministration, SQL Server
DBCC Commands in SQL ServerAdministration, SQL Server
Delayed Durability in SQL Server 2014Administration, SQL Server
Fixing SQL Server Database CorruptionAdministration, SQL Server
Improving SQL Server Query Performance with Indexes - Part 1Administration, SQL Server
Improving SQL Server Query Performance with Indexes - Part 2Administration, SQL Server
Introduction to R ServicesAdministration, SQL Server, SQL Server 2016
Managing System Databases in SQL ServerAdministration, SQL Server
Monitoring SQL Server with Extended EventsAdministration, SQL Server
Moving User Databases in SQL ServerAdministration, SQL Server
New Security Features in SQL Server 2016Administration, SQL Server 2016
Non-Clustered ColumnStore Indexes in SQL Server 2014Administration, SQL Server 2014
Partitioning in SQL ServerAdministration, SQL Server
Query Store, Live Query Statistics and Live Query PlansAdministration, SQL Server 2016
Securing SQL Server - Part 1Administration, SQL Server
SQL Server Advanced Index OperationsAdministration, SQL Server
SQL Server Backup and RestoreAdministration, SQL Server
SQL Server Basic Query Tuning TechniquesAdministration, SQL Server
SQL Server Change Data CaptureAdministration, SQL Server
SQL Server Clustered Index InternalsAdministration, SQL Server
SQL Server Data EncryptionAdministration, SQL Server
SQL Server Database MaintenanceAdministration, SQL Server
SQL Server Deadlock BasicsAdministration, SQL Server
SQL Server Deadlock TypesAdministration, SQL Server
SQL Server Extended Events BasicsAdministration, SQL Server
SQL Server Heap InternalsAdministration, SQL Server
SQL Server LatchesAdministration, SQL Server
SQL Server Non-Clustered Index InternalsAdministration, SQL Server
SQL Server Parameter SniffingAdministration, SQL Server
SQL Server Point-In-Time RecoveryAdministration, SQL Server
SQL Server Policy Based ManagementAdministration, SQL Server
SQL Server Resource GovernorAdministration, SQL Server
SQL Server Showplan Operator - Part 2Administration, SQL Server
SQL Server Showplan Operators - Part 1Administration, SQL Server
SQL Server Statistics InternalsAdministration, SQL Server
SQL Server Storage Internals - Part 1Administration, SQL Server
SQL Server Storage Internals - Part 2Administration, SQL Server
SQL Server Transaction Log Internals - Part 1Administration, SQL Server
SQL Server Transaction Log ManagementAdministration, SQL Server
SQL Server Wait Types - Part 1Administration, SQL Server
SQL Server Wait Types - Part 2Administration, SQL Server
SQL Server Plan Cache Recompilation and ReuseAdministration, SQL Server
Stretch DatabaseAdministration, SQL Server, SQL Server 2016
Temporal Tables in SQL Server 2016 - Part 1Administration, SQL Server 2016
Temporal Tables in SQL Server 2016 - Part 2Administration, SQL Server 2016
Troubleshooting Metadata Corruption in SQL ServerAdministration, SQL Server
Troubleshooting SQL Server with WinDbgAdministration, SQL Server
Using Query and Table Hints in SQL ServerAdministration, SQL Server
SQL Server Thread Life CycleAdministration, SQL Server
SQL Server TempdbAdministration, SQL Server
SQL Server Memory - Monitoring Buffer PoolAdministration, SQL Server
Analyzing Minimally Logged Operations in SQL ServerDevelopment, SQL Server
Constraints in SQL ServerDevelopment, SQL Server
Delete vs Truncate in SQL ServerDevelopment, SQL Server
Deleting Data in SQL ServerDevelopment, SQL Server
Error Handling in SQL ServerDevelopment, SQL Server
Inserting Data in SQL ServerDevelopment, SQL Server
JSON Support in SQL Server 2016Development, SQL Server 2016
LAG and LEAD Functions in SQL ServerDevelopment, SQL Server
Logical and Physical Query Processing in SQL ServerDevelopment, SQL Server
Merging Data in SQL ServerDevelopment, SQL Server
OFFSET and FETCH in SQL ServerDevelopment, SQL Server
Optimizing SQL Server Stored ProceduresDevelopment, SQL Server
Pivoting in SQL ServerDevelopment, SQL Server
Working With SEQUENCE in SQL ServerDevelopment, SQL Server
SQL Server Advanced AggregationsDevelopment, SQL Server
SQL Server Advanced Query TuningDevelopment, SQL Server
SQL Server AggregationsDevelopment, SQL Server
SQL Server Data Types - Part 1Development, SQL Server
SQL Server Data Types - Part 2Development, SQL Server
SQL Server DDL TriggersDevelopment, SQL Server
SQL Server DML OptimizationDevelopment, SQL Server
SQL Server DML TriggersDevelopment, SQL Server
SQL Server Dynamic SQLDevelopment, SQL Server
SQL Server Execution PlansDevelopment, SQL Server
SQL Server JoinsDevelopment, SQL Server
SQL Server Performance Tuning using Trace FlagsDevelopment, SQL Server
SQL Server Ranking FunctionsDevelopment, SQL Server
SQL Server Set OperatorsDevelopment, SQL Server
SQL Server Stored ProceduresDevelopment, SQL Server
SQL Server Temporary Tables and Table VariablesDevelopment, SQL Server
SQL Server Temporary TablesDevelopment, SQL Server
Subqueries in SQL ServerDevelopment, SQL Server
Table Expressions in SQL ServerDevelopment, SQL Server
TOP and APPLY Operators in SQL ServerDevelopment, SQL Server
Updating Data in SQL ServerDevelopment, SQL Server
User Defined Functions in SQL ServerDevelopment, SQL Server
Views in SQL ServerDevelopment, SQL Server
Working with Date and Time Datatypes in SQL ServerDevelopment, SQL Server
Working with NULL in SQL ServerDevelopment, SQL Server
XML and Xquery in SQL ServerDevelopment, SQL Server
Advanced Data Cleansing In SSISSSIS
Calling WebService From SSISSSIS
Error and EventHandling in SSISSSIS
Implementing Incremental Data Load and Inner Join in SSISSSIS
Slowly Changing Dimension In SSISSSIS
SSIS Data Flow Transformations Part 1SSIS
SSIS Data Flow Transformations Part 2SSIS
SSIS Data Loading - Part 1SSIS
SSIS Foreach Loop ContainerSSIS
Task Group Sequence and For loop Containers in SSISSSIS
Financial Dashboard in Power BIPower BI
Managing Relationships in Power BIPower BI
Power BI AdministrationPower BI
Sales Dashboard in Power BIPower BI
Shape and Transform Data in Power BIPower BI
Streaming Data From SQL Server To Power BIPower BI
Web and Social Analytics Dashboard in Power BIPower BI
Deploying Predictive Model As Web Service with Azure ML StudioMachine Learning
Implementing Linear Regression with Azure Machine Learning StudioMachine Learning
Predicting Diamond Rates with Azure ML StudioMachine Learning
Create and Manage Azure SQL Data WarehouseAzure SQL Data Warehouse
Load Data into SQL Data Warehouse with Data FactoryAzure Data Factory, Azure SQL Data Warehouse
Azure SQL Database Backup and RestoreAzure SQL Database
Migrating On-Premise SQL Server Database To Azure SQL DatabaseAzure SQL Database
Securing Azure SQL DatabasesAzure SQL Database
Move Data Between On-Premise and Cloud using Azure Data FactoryAzure Data Factory
Transform Data in Azure Data Factory using Visual Studio - Hive ActivityAzure Data Factory
Transform Data Using Azure Data FactoryAzure Data Factory
Lab TitleDownload
Clustered Index Internals[wpdm_package]
Calling Web Service From SSIS[wpdm_package]
Extended Events Part 1[wpdm_package]
Deploying Predictive Model as Web Service with Azure ML Studio[wpdm_package]
Subscription TypePriceFeatures
Gold USD $49 INR 3450 Per Month + 18% GST = 4071/-Unlimited access to full HOLs library for a month
Diamond USD 499 INR 34500 Per Year + 18% GST = 40710/-Unlimited access to full HOLs library for an year

' src=

This is really uniue i could not find anything like this on internet. very helpful in practicing

' src=

Thank you for the lifetime model, i had always wanted that 🙂

' src=

If we take the video course subscription, then do we get all the scripts an materials, so that we practice the same.

' src=

I need some clarification regarding vedios courses and its accessibilty duration. Could you please call if possible to discuss the same.

' src=

I am interested but not sure to buy since i do not if the books are updated , the current SQL Version is 2022 and it seems to be done for 2014

Leave A Comment Cancel reply

Save my name, email, and website in this browser for the next time I comment.

Assignment Lab 02

  • Information Systems

sql lab assignment

  • Copilot Studio

Microsoft Copilot Studio: Building copilots with agent capabilities

  • By Omar Aftab

Copilot Studio homepage user interface

  • Copilot category
  • Announcements

At Microsoft Build 2024 , we’re excited to announce a host of new powerful capabilities in   Microsoft Copilot Studio —t he single conversational AI tool you can use to create your very own custom copilots or extend Microsoft C opilot experiences with your own enterprise data and scenarios. The first of these are c opilots that can now act as independent agents— ones that can be triggered by events— not just conversation— and can automa te and orchestrate complex, long-running business processes with more autonomy and less human intervention.

For instance, consider the potential of a copilot that can react when an email arrives, look up the sender’s details, see their previous communications, and use generative AI to trigger the appropriate chain of actions in their response. From understanding the intent of the email, to look ing up the sender’s details and account , see ing their previous communications, checking inventory,   responding to the sender asking for their preferences, and then taking the appropriate actions to close a ticket — orchestrating and shepherding an entire process over days.  

With such capabilities, copilots are evolving from those that work with you to those that work for you. They can be designed to handle specific roles or functions, such as IT, marketing, sales, customer success, and finance across various industries, including travel, retail, and financial services.  

With these new capabilities, here are some examples of the kinds of copilots our customers can build

  • IT help desk .  IT support is complex, involving tickets, order numbers, approvals, and stock levels . O pening and closing a ticket can be a long-running task that spans days. A copilot can now handle this process, interfacing with IT service management applications, resolving IT tickets with context and memory, creating purchase orders for device refresh, and reaching out and getting managers approvals — all independently .
  • Employee onboarding . Onboarding new employees is often expensive and slow. Now, imagine you’re a new hire. A copilot greets you, reasons over HR data, and answers your questions. It introduces you to your buddy, provides training and deadlines, assists with forms, and sets up your first week of meetings. Throughout all of this, the copilot is in touch, guiding you through the weeks -long onboarding and account set up processes.  
  • Personal concierge for sales and service . Balancing exceptional customer experience while meeting ambitious revenue goals can be challenging. When a copilot serves guests, i t can use the memory of previous conversations with guests to remember their preferences, make reservations, handle complaints, and answer questions related to the products and services on offer. The copilot learns from its interactions and proposes new ways of handling customer scenarios. By doing so, copilots can increase upsell and attachment rates, driving revenue for the resort while simultaneously enhancing guest experience, satisfaction rates, and repeat business.

Let’s dig deeper into a few of the underlying capabilities that make all this possible:

  • Asynchronous orchestration of complex tasks . The first is the ability to use generative AI- powered   planning and reasoning to manage complex, multi step, long-running tasks. For example, reacting to a new order means determining the need to verify inventory, trigger ing the right payment processes, pinging a supervisor for approval if the amount is above a certain threshold, and replying with a confirmation. Many of these events can take hours—or even days— to complete, but the copilot will run through them , maintaining the necessary state and context to do so.
  • Memory and context . One of the frustrating things about support has traditionally been having to repeat information: who you are, what your policy number is, what your address is. There is no continuity of conversation. Copilots will now learn from previous conversations from the users and utilize this knowledge to continually personalize interactions . A copilot may not need to ask you for your laptop model or your address when you call again for the same issue. Conversations will thus become long-running, contextual, and deeply personalized.
  • Monitor, learn, and improve . Copilots can now learn and adapt, offering monitoring and teaching capabilities to make their interactions better. Each copilot records a comprehensive history of its activities, providing transparency into its performance, including user interactions, actions taken, and feedback received, and you can see what decisions it made — and correct and teach them — with just a few clicks.

placeholder

  • Delegation with confidence and guardrails . When developing copilots with agent capabilities, establishing clear boundaries is paramount. Copilots operate strictly within the confines of the maker-defined instructions, knowledge, and actions. The data sources linked to the copilot adhere to stringent security measures and controls, managed through the unified admin center of Copilot Studio. This includes data loss prevention, robust authentication protocols, and more.

The se advanced new capabilities in Copilot Studio are currently accessible to customers participating in an Early Access Preview where organizations such as Centro de la Familia are excited to explore agent capabilities that support teachers and case workers, allowing them to spend less time on administrative tasks and more time working with children, ultimately leading to better child outcomes . Based on feedback from program participants, we will continue to iterate and refine these capabilities for broader access in a preview planned for later this year .  

Additional innovations with Copilot Studio

There’s a lot more to share at Microsoft Build with Copilot Studio, and we’ll touch on just a few of our new capabilities here. To learn more — just sign up and try it out for yourself here .

Screenshot of the homepage of Microsoft Copilot Studio

Here are a few examples of how Copilot connectors can transform copilot experiences for specific personas or functions:

  • Legal and Compliance . Navigate complex legal landscapes with a Copilot extension that queries specific legal datasets, ensuring controlled and compliant responses without overwhelming users with extraneous information.
  • HR Helper . Assist employees with accessing essential resources for benefits and PTO policies, and even book time off directly through Copilot.
  • Incident Report Coordinator . Workers can locate the right documentation, report incidents, and track them efficiently, all within the context of the chat.

Starting in June 2024, developers can access the public preview for Copilot connectors and stay informed on updates here .

Conversational analytics (private preview) : One of the most common asks from customers has been the need for deeper insight into what their copilot is doing, how generative AI is responding, when it was unable to give the right answers and why — and recommendations on what to do to improve it.

Screenshot of the conversational analytics experience in Microsoft Copilot Studio

Enhanced security and controls (public preview ) : Administrators can now configure advanced settings beyond the default security measures and controls. With Microsoft Purview , Copilot Studio administrators gain access to more detailed governance tools, including audit logs, inventory capabilities, and sensitivity labels. They will be able to review comprehensive audit logs that cover tenant-wide usage, inventory (with API support), and tenant hygiene (such as data loss prevention violations and inactive copilots), enabling them to effectively monitor business impact. Both creators and end-users will be able to view sensitivity labels when responses are generated using AI-powered answers based on SharePoint documents.

With all the amazing innovations, numerous organizations are using Copilot Studio to build transformative generative AI-powered solutions. Check out this story from Nsure on how they are using Copilot Studio:

Get started today with Copilot Studio

This is just a glimpse of all the exciting innovation around copilots and Copilot Studio — we have a host of exciting new capabilities to share in our sessions at Build. So, join us in watching the sessions below, and try out Copilot Studio yourself and build and share your very own copilot in minutes.

Watch the sessions at Microsoft Build:

  • “ Microsoft Build opening keynote ”
  • “ Next generation AI for developers with the Microsoft Cloud ”
  • “ Shaping next-gen development: the future of Copilot in Power Platform ”

Deeper dives:

  • Breakout: “ What’s new with Microsoft Copilot Studio ”
  • Breakout with demos: “ Build your own copilot with Microsoft Copilot Studio ”
  • Breakout with demos: “ Build Microsoft Copilot extensions with Copilot Studio ”
  • Demo (live only): “ Build your own Copilot extension with Microsoft Copilot Studio ”

IMAGES

  1. SQL LAB TEST

    sql lab assignment

  2. SQL Lab 2: Basic SQL Statements for Multiple Tables with

    sql lab assignment

  3. Lab Assignment-1

    sql lab assignment

  4. SQL LAB Assignment

    sql lab assignment

  5. LAB Assignment

    sql lab assignment

  6. Basic SQL Statements on Multiple Tables using Aggregate

    sql lab assignment

VIDEO

  1. Exeriment-3: Queries 3,10,13,14, and 15

  2. SQL LAB 9

  3. SQL LAB 2

  4. Database Development and Design: Week 4: SQL Lab 3 Walkthrough

  5. SQL LAB 8

  6. Database Schema for a student-Lab scenario

COMMENTS

  1. Sagnik1004/SQL-Lab-Assignment-: 2nd SQL assignment

    SQL-Lab-Assignment-. 2nd SQL assignment. We have been provided a database schema on supply chain data. Then we have been asked to write queries in a sql script file to answer various business questions.

  2. SQL Exercises

    Exercises. We have gathered a variety of SQL exercises (with answers) for each SQL Chapter. Try to solve an exercise by filling in the missing parts of a code. If you're stuck, hit the "Show Answer" button to see what you've done wrong.

  3. SQL Exercises, Practice, Solution

    What is SQL? SQL stands for Structured Query Language and it is an ANSI standard computer language for accessing and manipulating database systems. It is used for managing data in relational database management system which stores data in the form of tables and relationship between data is also stored in the form of tables. SQL statements are ...

  4. SQL Exercises

    SQL (Structured Query Language) is a powerful tool used for managing and manipulating relational databases.Whether we are beginners or experienced professionals, practicing SQL exercises is essential for our skills and language mastery. In this article, we'll cover a series of SQL practice exercises covering a wide range of topics suitable for beginners, intermediate, and advanced learners.

  5. Advanced SQL Practice: 10 Exercises with Solutions

    The RANK() function assigns the same rank if multiple consecutive rows have the same value. Then, the next row gets the next rank as if the previous rows had distinct values. Here, the ranks 1,1,1 are followed by 4 (as if it was 1,2,3 instead of 1,1,1).. The DENSE_RANK() function also assigns the same rank if multiple consecutive rows have the same value.

  6. Basic SQL Query Practice Online: 20 Exercises for Beginners

    SQL Query Practice. Dataset. Exercise #1: Show the Final Dates of All Events and the Wind Points. Exercise #2: Show All Finals Where the Wind Was Above .5 Points. Exercise #3: Show All Data for All Marathons. Exercise #4: Show All Final Results for Non-Placing Runners. Exercise #5: Show All the Result Data for Non-Starting Runners.

  7. 10 Beginner SQL Practice Exercises With Solutions

    online practice. sql practice. Table of Contents. The Dataset. Exercise 1: Selecting All Columns From a Table. Exercise 2: Selecting a Few Columns From a Table. Exercise 3: Selecting a Few Columns and Filtering Numeric Data in WHERE. Exercise 4: Selecting a Few Columns and Filtering Text Data in WHERE.

  8. Lab 9

    In this Lab, you will get practice with more advanced SQL queries, particularly with multi-table queries (joins). Join queries tend to be more tricky to design and write, but are one of the most powerful features of relational databases. This lab will particularly be useful for practicing JOINs for the Final Exam. We will use the CSE 154 Query ...

  9. SQL: A Practical Introduction for Querying Databases

    There are 5 modules in this course. Much of the world's data lives in databases. SQL (or Structured Query Language) is a powerful programming language that is used for communicating with and manipulating data in databases. A working knowledge of databases and SQL is a must for anyone who wants to start a career in Data Engineering, Data ...

  10. Assignment 1 « SQL

    Assignment 1 « SQL ... There are some really useful hints and examples you can borrow from the lab for this assignment. The database and schema are described again below, but are the same from the lab. We have provided a database named people.db with the name, age, ID, and occupation of some Brown students and alumni. Here is the schema: ...

  11. 3.13 Lab: Working with a SQL database

    3.13.4 Grouping and aggregating. SQL makes it really easy to compute aggregate statistics of one column based on values of a different column, with a series of built-in functions (COUNT, AVG, MAX, MIN…). Let's now see a few examples of this type of queries: # use COUNT with * to return the total number of rows dbGetQuery (db, 'SELECT COUNT ...

  12. DBMS Lab Assignments

    The document outlines assignments for a database management system lab involving creating tables, inserting data, writing SQL queries, and using PL/SQL. It includes instructions to create tables for departments, employees, and projects with defined columns and constraints. Data is to be inserted and various SQL queries written to retrieve, modify, and analyze the data. PL/SQL programs are to ...

  13. Lab 2 basic SQL

    0629227. For this lab we're going to be working in phpMyAdmin to create tables from csv files. Using csv files from blackboard, we're going to need boats, reserves, and sailors. From there we're going to start from your username in the phpMyAdmin sidebar, and we're going to continue to the import tab.

  14. Solved SQL Lab Assignment 6: Answer the questions below in

    SQL Lab Assignment 6: Answer the questions below in SQL queries. The purpose of this assignment is to demonstrate that you can execute statements that are used to add, change, and delete data in relational database tables. These problems require knowledge of the INSERT, UPDATE, and DELETE statements. SQL Database and Column names listed below ...

  15. Lab-1 Assignment Introduction to SQL (DBMS)

    Lab-1 Assignment Introduction to SQL (DBMS) Lab-1 Assignment Introduction to SQL (DBMS) Course. Database Management System (CS 2004) 93 Documents. Students shared 93 documents in this course. University Kalinga Institute of Industrial Technology. Academic year: 2021/2022. Uploaded by:

  16. SQL Server Hands-On-Labs

    With each lab, you can practice a specific concept step-by-step. SQLMaestros Hands-On-Labs enables the practical way of learning. With our HOL documents you will get hands-on with hundreds of topics in SQL Server & Microsoft Data Platform. The best way to learn is to do-it-yourself, so please stop being lazy and start practicing.

  17. DBMS Lab Assignment 8

    DBMS LAB ASSIGNMENT 8 - Free download as PDF File (.pdf), Text File (.txt) or read online for free. The document provides instructions for creating tables, inserting sample data, and writing SQL queries on the tables for a database assignment. The tables to be created are Salesman_Details, Customer_Details, and Orders with attributes like salesman ID, name, city, commission, customer ID, name ...

  18. Learn SQL

    Practice SQL querys with an online terminal. Solve SQL query questions using a practice database. Learn and improve your SQL skills.

  19. SQL Practical Assignment

    SQL PRACTICAL ASSIGNMENT Lab Activity 1: Create a table STUDENT with under mentioned structure by using SQL Statement: StdID Number Primary Key StdName Character (30) NOT NULL Sex Character(6) Male or Female Percentage Number SClass Number Sec Character Stream Character(10) Science or Commerce

  20. CS 122: SQL Lab

    CS 122: SQL Lab. CS 122: SQL Lab. Due: March 7th at 6pm. You should work alone on this lab, which is designed to give you experience with writing SQL queries. Your task is to do the exercises in Sections 2 through 6. To get started run svn up to pick up the materials for this lab (week8). To submit your solutions, cut and paste your query and ...

  21. Assignment Lab 02 (pdf)

    Assignment Lab 02 | 7.5 % of the final Grade Individual Assignment 9. Write a SQL queries to get the Average duration of movies. 10. Write a SQL queries to get the List of genres with the highest number of titles. Submission Requirements: 1. Submit the SQL scripts used to create tables, insert data, and perform queries. 2.

  22. DBMS Lab Assignment Questions

    Questions. These are questions for assignment 1. The solution is available after the last question. Question (A) Develop a SQL query to list details of Departments that offer more than 3 branches. Question (B) Develop a SQL query to list the details of Departments that offer more than 6 courses.

  23. SQL Lab Assignment On Normalization

    SQL LAB ASSIGNMENT ON NORMALIZATION - Free download as Word Doc (.doc / .docx), PDF File (.pdf), Text File (.txt) or read online for free. This document contains instructions for an assignment involving creating and populating database tables in SQL. It defines two tables - a client master table with client details and a product master table with product inventory information.

  24. SQL ASSIGNMENT Access Module 10 Lab...

    Lab 1: Querying the Gardening Supply Database Using SQL o DOWNLOAD the Gardening.accdb database. we have converted everything to standard SQL. All spaces have been removed from table and field names, so that you NEVER will use any brackets or spaces in these names in queries (see AC 548). For a hypothetical database, you would type SELECT AcctNum, AcctName, etc., not SELECT [Acct Num], [Acct ...

  25. Data Warehouse Fundamentals

    Final Assignment: Data Warehouse Fundamentals • 90 minutes Obtain IBM Cloud Feature Code and Activate Trial Account • 60 minutes Hands-on Lab: Populating a Data Warehouse using IBM Db2 • 15 minutes

  26. Microsoft Copilot Studio: Building copilots with agent capabilities

    With these new capabilities, here are some examples of the kinds of copilots our customers can build: IT help desk. IT support is complex, involving tickets, order numbers, approvals, and stock levels. O pening and closing a ticket can be a long-running task that spans days. A copilot can now handle this process, interfacing with IT service management applications, resolving IT tickets with ...