parent
2e849c0043
commit
d20c253e2b
8 changed files with 68 additions and 13 deletions
@ -0,0 +1,55 @@ |
||||
--- |
||||
title: Challenge 1 |
||||
description: Write a SQL query to create a `books` table with specific columns. |
||||
order: 300 |
||||
type: challenge |
||||
initSteps: [] |
||||
expectedResults: |
||||
- columns: [message] |
||||
values: |
||||
- ['Table created successfully'] |
||||
--- |
||||
|
||||
You are tasked with creating a table named `books` for a bookstore database. The table should have the following columns: |
||||
|
||||
| Column Name | Data Type | Constraints | |
||||
| -------------- | -------------- | ----------------- | |
||||
| id | INTEGER | PRIMARY KEY | |
||||
| title | TEXT | NOT NULL | |
||||
| author | TEXT | NOT NULL | |
||||
| genre | TEXT | | |
||||
| price | NUMERIC(10, 2) | CHECK (price > 0) | |
||||
| published_date | DATE | | |
||||
|
||||
### Requirements |
||||
|
||||
1. The `id` column should uniquely identify each book. |
||||
2. The `title` and `author` columns cannot be null. |
||||
3. The `price` column must be greater than 0. |
||||
|
||||
### Task |
||||
|
||||
Write a SQL query to create the `books` table as described above. |
||||
|
||||
### Expected Output |
||||
|
||||
After running your query, the output should confirm the creation of the table: |
||||
|
||||
| message | |
||||
| -------------------------- | |
||||
| Table created successfully | |
||||
|
||||
### Example Query (Partial) |
||||
|
||||
```sql |
||||
CREATE TABLE books ( |
||||
id INTEGER PRIMARY KEY, |
||||
title TEXT NOT NULL, |
||||
author TEXT NOT NULL, |
||||
genre TEXT, |
||||
price NUMERIC(10, 2) CHECK (price > 0), |
||||
published_date DATE |
||||
); |
||||
``` |
||||
|
||||
Now, complete the challenge and create the table! |
@ -1,7 +1,7 @@ |
||||
--- |
||||
title: Challenge 2 |
||||
title: Expression Projection |
||||
description: Write a SQL query to find the total number of orders in the `orders` table. |
||||
order: 300 |
||||
order: 310 |
||||
type: challenge |
||||
initSteps: |
||||
- CREATE TABLE books ( |
@ -1,7 +1,7 @@ |
||||
--- |
||||
title: Challenge 4 |
||||
title: Logical Operators |
||||
description: Write a SQL query to find the total number of orders in the `orders` table. |
||||
order: 400 |
||||
order: 340 |
||||
type: challenge |
||||
initSteps: |
||||
- CREATE TABLE books ( |
@ -1,5 +1,5 @@ |
||||
--- |
||||
title: Challenge 1 |
||||
title: Projection Challenge |
||||
description: Write a SQL query to find the total number of orders in the `orders` table. |
||||
order: 300 |
||||
type: challenge |
@ -1,7 +1,7 @@ |
||||
--- |
||||
title: Challenge 7 |
||||
title: Sorting and Filtering |
||||
description: Write a SQL query to find the total number of orders in the `orders` table. |
||||
order: 700 |
||||
order: 370 |
||||
type: challenge |
||||
initSteps: |
||||
- CREATE TABLE orders ( |
@ -1,7 +1,7 @@ |
||||
--- |
||||
title: Challenge 6 |
||||
title: Sorting and Limiting |
||||
description: Write a SQL query to find the total number of orders in the `orders` table. |
||||
order: 600 |
||||
order: 360 |
||||
type: challenge |
||||
initSteps: |
||||
- CREATE TABLE orders ( |
@ -1,7 +1,7 @@ |
||||
--- |
||||
title: Challenge 5 |
||||
title: Sorting Challenge |
||||
description: Write a SQL query to find the total number of orders in the `orders` table. |
||||
order: 500 |
||||
order: 350 |
||||
type: challenge |
||||
initSteps: |
||||
- CREATE TABLE books ( |
@ -1,7 +1,7 @@ |
||||
--- |
||||
title: Challenge 3 |
||||
title: Unique Projection |
||||
description: Write a SQL query to find the total number of orders in the `orders` table. |
||||
order: 300 |
||||
order: 330 |
||||
type: challenge |
||||
initSteps: |
||||
- CREATE TABLE orders ( |
Loading…
Reference in new issue