sql-masterclass's People
Forkers
chiahsuy mattburnham aba0405 robiriu harshithbejjam williamtindan bhascarp sunjoshi1991 rashkam01 ayoub-berdeddouch phagoroyebabs nmangera olayinkaf cyyyp4erpnk saketh-12 gyanachand1 shreyachatterjee-blip ritikkumarjain nidhig631 sarmoho shreyas-05 anefuiii mmak3208 mehmeterkangunal yaseen221 muditnandwana ifyfrances mattcon70 vijayalakshmisivaraman vijay6568 da-vansh sfliew lalithh24 chethangr maxcodextc gabriela-machado ud-anurag nikkitha92 revanth-sridhar sgatea bounasrnour singhshanu suchayan01 kesthav domnicads anubhav-pandey1 mtahir19 bhavik-ksvss shek-attack chetnakhanna16 nooea justjooney sgpohlj87 anikait1 99701a0554 motamedw anirban6393 karthikvcp1995 clickio mes4849 ibraabukaff simran-barnwal harshasanthapur harry-data-g desfados gpozzi jeanvitola harshitasing skybe077 carlosbtech visrun chuktuk mekongdelta-mind quantumdemon1 agsigmoid khurramkhalidiqbal machein cybernetics suryatmodulus occultism ryukanjit yoleitza regulus1492 smt100 sebidelamata prachie6157 telixia shahidshakil shivakoreddi basavaraj-hadapad bijornxavier romanmaltcev mainakmaitra fjramadhn datalearns zhry600 jmiguelfernandes jasonkasuma cleebot gunjanjksql-masterclass's Issues
Extra Brackets
For lesson 3, there is no need for an extra bracket in the last wrong code on the page.
Query on platform as at now
SELECT
ticker,
SUM(CASE WHEN price > open THEN 1 ELSE 0 END) / COUNT(*)) AS breakout_percentage,
SUM(CASE WHEN price < open THEN 1 ELSE 0 END) / COUNT(*)) AS non_breakout_percentage
FROM trading.prices
WHERE market_date >= '2019-01-01' AND market_date <= '2019-12-31'
GROUP BY ticker;
Correct Query
SELECT
ticker,
SUM(CASE WHEN price > open THEN 1 ELSE 0 END) / COUNT(*) AS breakout_percentage,
SUM(CASE WHEN price < open THEN 1 ELSE 0 END) / COUNT(*) AS non_breakout_percentage
FROM trading.prices
WHERE market_date >= '2019-01-01' AND market_date <= '2019-12-31'
GROUP BY ticker;
Question 3,4, and 5 Errors
Question 3 and 4 are missing a WHERE clause to specify BTC/ETH.
Question 5 eth_sell_qty is actually the BTC sell qty.
Transactions table missing a column
My transactions table is missing the txn_date column, I am using the schema provided
Step 4 Question 3 wrong answer
The question is For each year, calculate the following buy and sell metrics for Bitcoin:
The SQL answer is :
SELECT
EXTRACT(YEAR FROM txn_date) AS txn_year,
txn_type,
COUNT(*) AS transaction_count,
ROUND(SUM(quantity)::NUMERIC, 2) AS total_quantity,
ROUND(AVG(quantity)::NUMERIC, 2) AS average_quantity
FROM trading.transactions
GROUP BY txn_year, txn_type
ORDER BY txn_year, txn_type;
Missing Where ticker='BTC'
The answer table is wrong as well.
Step 4. Question 3. There are two Question 3.
There are two Question 3, asking for different questions.
Filter for ETH ticker missing in Step 3 - Daily Prices Question 6
What is the monthly average of the price column for Ethereum in 2020? Sort the output in chronological order and also round the average price value to 2 decimal places
Question 6 asks to calculate monthly average price for Ethereum in 2020, however the solution is missing a where clause for the same.
Current Solution
SELECT
DATE_TRUNC('MON', market_date) AS month_start,
-- need to cast approx. floats to exact numeric types for round!
ROUND(AVG(price)::NUMERIC, 2) AS average_eth_price
FROM trading.prices
WHERE EXTRACT(YEAR FROM market_date) = 2020
GROUP BY month_start
ORDER BY month_start;
Correct Solution
SELECT
DATE_TRUNC('MON', market_date) AS month_start,
-- need to cast approx. floats to exact numeric types for round!
ROUND(AVG(price)::NUMERIC, 2) AS average_eth_price
FROM trading.prices
WHERE EXTRACT(YEAR FROM market_date) = 2020 AND ticker = 'ETH'
GROUP BY month_start
ORDER BY month_start;
Error While Loading the data set to MY SQL Workbench
Hello @datawithdanny ,
I am currently facing an issue while running SQL script on SQL workbench. The issue occurs when I am trying to load the data in the transaction table. It says there is an incorrect date-time value for id 774.
Please let me know what can be done in this case.
Sql course
Filter for ETH ticker missing in step 4, Q4
GUI is not opening
I have run docker -compose up
and it builds successfully. When I open localhost : 3000 , it's not working
here are some ref screenshots :-
How to fix this issue?
Thanks
Wrong Answer for Step-2 (Question-6)
For that question, the answer should be 11. Instead, there is a list of the different countries which was the answer for the previous question. I guess it's just a small mistake however, I just want to point out for future improvement.
Thank You for this course
Wrong solution for Question 6 in step4.md
The solution for Question 6 in step4.md is wrong.
Question - Summarise all buy and sell transactions for each member_id by generating 1 row for each member with the following additional columns:
- Bitcoin buy quantity
- Bitcoin sell quantity
- Ethereum buy quantity
- Ethereum sell quantity
Given Solution -
SELECT
member_id,
SUM(
CASE
WHEN ticker = 'BTC' AND txn_type = 'BUY' THEN quantity
ELSE 0
END
) AS btc_buy_qty,
SUM(
CASE
WHEN ticker = 'BTC' AND txn_type = 'SELL' THEN quantity
ELSE 0
END
) AS btc_sell_qty,
SUM(
CASE
WHEN ticker = 'ETH' AND txn_type = 'BUY' THEN quantity
ELSE 0
END
) AS eth_buy_qty,
SUM(
CASE
WHEN ticker = 'BTC' AND txn_type = 'SELL' THEN quantity
ELSE 0
END
) AS eth_sell_qty
FROM trading.transactions
GROUP BY member_id;
Issue - In the last case, the ticker is filtered with BTC, it should be ETH.
Correct solution -
SELECT
member_id,
SUM(
CASE
WHEN ticker = 'BTC' AND txn_type = 'BUY' THEN quantity
ELSE 0
END
) AS btc_buy_qty,
SUM(
CASE
WHEN ticker = 'BTC' AND txn_type = 'SELL' THEN quantity
ELSE 0
END
) AS btc_sell_qty,
SUM(
CASE
WHEN ticker = 'ETH' AND txn_type = 'BUY' THEN quantity
ELSE 0
END
) AS eth_buy_qty,
SUM(
CASE
WHEN ticker = 'ETH' AND txn_type = 'SELL' THEN quantity
ELSE 0
END
) AS eth_sell_qty
FROM trading.transactions
GROUP BY member_id;
Step 3. Question 6. Answer is not considering 'ETH' filter
Question specifies "average of the price column for Ethereum", but in answer code and results table the 'ETH' filter is not considered in WHERE clausule.
SELECT
DATE_TRUNC('MON', market_date) AS month_start,
-- need to cast approx. floats to exact numeric types for round!
ROUND(AVG(price)::NUMERIC, 2) AS average_eth_price
FROM trading.prices
WHERE ticker = 'ETH'
AND EXTRACT(YEAR FROM market_date) = 2020
GROUP BY month_start
ORDER BY month_start;
</details>
<br>
| month_start | average_eth_price |
| ---------------------- | ----------------- |
| 2020-01-01 | 156.65 |
| 2020-02-01 | 238.76 |
| 2020-03-01 | 160.18 |
| 2020-04-01 | 171.29 |
| 2020-05-01 | 207.45 |
| 2020-06-01 | 235.92 |
| 2020-07-01 | 259.57 |
| 2020-08-01 | 401.73 |
| 2020-09-01 | 367.77 |
| 2020-10-01 | 375.79 |
| 2020-11-01 | 486.73 |
| 2020-12-01 | 622.35 |
<br>
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.