Exercise 1

For this exercise I've created a db fiddle that sets up a table and adds some data.

The company you work for has set up a lower limit of the salaries of employees. No employee may earn less than 35000.

Update the data in the provided table so that no employee earns less than 35000.


Exercise 2

For this exercise I've created another db fiddle that sets up a table and adds some data.

You have been working on a simple SQL to-do application that has a single table of to-do task ids, what the task involves, their due date, and whether they've been completed or not (0 means not completed, 1 means completed).


The tasks table is shown below (or in the fiddle above):


| id  | content                       | due        | completed |
| --- | ----------------------------- | ---------- | --------- |
| 1   | Start learning about SQL      | 2020-06-01 | 1         |
| 2   | Start section 2 of the course | 2020-06-08 | 0         |
| 3   | Master SQL and PostgreSQL     | 2020-06-23 | 0         |
| 4   | Use SQL with Python           | 2020-06-18 | 1         |


You have just completed tasks 2 and 3. Update the table to reflect that.


Solutions

Here's the solution for exercise 1:

UPDATE employees
SET salary = 35000
WHERE salary < 35000;


Remember to check the output after!

SELECT * FROM employees WHERE salary < 35000;


That query should return nothing.


Here's the solution for exercise 2:

UPDATE tasks
SET completed = 1
WHERE id = 2 OR id = 3;


Then double-check the output to make sure all tasks are completed:

SELECT * FROM tasks;