Skip to content

Commit d5cf278

Browse files
committed
Upload 168
1 parent 767fdd4 commit d5cf278

File tree

2 files changed

+77
-1
lines changed

2 files changed

+77
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- markdownlint-disable MD041 -->
22
[![eevveerryyddaayy release](https://img.shields.io/badge/eevveerryyddaayy-v1.3.0-blue.svg)](https://github.com/ggeerraarrdd/eevveerryyddaayy/)
3-
[![Solved](https://img.shields.io/badge/solved-167-green.svg)](#index)
3+
[![Solved](https://img.shields.io/badge/solved-168-green.svg)](#index)
44
<!-- markdownlint-enable MD041 -->
55

66
# SQL Everyday
@@ -201,6 +201,7 @@ Because this project necessitated a framework to enable consistent daily practic
201201
| 165 | [Daily Hospital Admissions and Discharges Report](https://www.codewars.com/kata/66b09bedf5ca866d7ffafc8f) | [Solution](solutions/165_daily_hospital_admissions_and_discharges_report.md) | Codewars | Medium | `TO_CHAR()` |
202202
| 166 | [Films selection with a twist](https://www.codewars.com/kata/644424f8d7bab510f1375d20) | [Solution](solutions/166_films_selection_with_a_twist.md) | Codewars | Medium | `PERCENTILE_DISC` |
203203
| 167 | [SQL Basics: Raise to the Power](https://www.codewars.com/kata/594a8f653b5b4e8f3d000035) | [Solution](solutions/167_sql_basics_raise_to_the_power.md) | Codewars | Easy | `^` or `POW()` |
204+
| 168 | [SQL Basics: Simple UNION ALL](https://www.codewars.com/kata/58112f8004adbbdb500004fe/sql) | [Solution](solutions/168_sql_basics_simple_union_all.md) | Codewars | Medium | |
204205
<!-- Index End - WARNING: Do not delete or modify this markdown comment. -->
205206
<!--- cSpell:enable --->
206207

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# SQL Everyday \#168
2+
3+
## SQL Basics: Simple UNION ALL
4+
5+
Site: Codewars\
6+
Difficulty per Site: Medium
7+
8+
## Problem
9+
10+
For this challenge you need to create a UNION statement, there are two tables `ussales` and `eusales` the parent company tracks each sale at its respective location in each table, you must all filter the sale price so it only returns rows with a sale greater than `50.00`. You have been tasked with combining that data for future analysis. Order by location (US before EU), then by id. [[Full Description](https://www.codewars.com/kata/58112f8004adbbdb500004fe/sql)]
11+
12+
## Submitted Solution
13+
14+
```sql
15+
-- Submitted Solution
16+
SELECT
17+
'US' AS location
18+
,id
19+
,name
20+
,price
21+
,card_name
22+
,card_number
23+
,transaction_date
24+
FROM ussales
25+
WHERE price > 50.00
26+
UNION ALL
27+
SELECT
28+
'EU' AS location
29+
,id
30+
,name
31+
,price
32+
,card_name
33+
,card_number
34+
,transaction_date
35+
FROM eusales
36+
WHERE price > 50.00
37+
;
38+
```
39+
40+
## Site Solution
41+
42+
```sql
43+
-- Codewars Solution
44+
select *
45+
from (select 'US' as location,
46+
id,
47+
name,
48+
price,
49+
card_name,
50+
card_number,
51+
transaction_date
52+
from ussales
53+
union all
54+
select 'EU' as location,
55+
id,
56+
name,
57+
price,
58+
card_name,
59+
card_number,
60+
transaction_date
61+
from eusales
62+
) s
63+
where s.price > 50
64+
```
65+
66+
## Notes
67+
68+
TBD
69+
70+
## NB
71+
72+
TBD
73+
74+
Go to [Index](../?tab=readme-ov-file#index)\
75+
Go to [Overview](../?tab=readme-ov-file)

0 commit comments

Comments
 (0)