-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa5bb2b
commit 7fd5d9a
Showing
3 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
# 1. Define variables | ||
# 2. Create a CTE that rounds the average views per video | ||
# 3. Select the column you need and create calculated columns from existing ones | ||
# 4. Filter results by Youtube channels | ||
# 5. Sort results by net profits (from highest to lowest) | ||
*/ | ||
|
||
|
||
-- 1. | ||
DECLARE @conversionRate FLOAT = 0.02; -- The conversion rate @ 2% | ||
DECLARE @productCost FLOAT = 5.0; -- The product cost @ $5 | ||
DECLARE @campaignCost FLOAT = 50000.0; -- The campaign cost @ $50,000 | ||
|
||
|
||
-- 2. | ||
WITH ChannelData AS ( | ||
SELECT | ||
channel_name, | ||
total_views, | ||
total_videos, | ||
ROUND((CAST(total_views AS FLOAT) / total_videos), -4) AS rounded_avg_views_per_video | ||
FROM | ||
youtube_db.dbo.view_uk_youtubers_2024 | ||
) | ||
|
||
-- 3. | ||
SELECT | ||
channel_name, | ||
rounded_avg_views_per_video, | ||
(rounded_avg_views_per_video * @conversionRate) AS potential_units_sold_per_video, | ||
(rounded_avg_views_per_video * @conversionRate * @productCost) AS potential_revenue_per_video, | ||
((rounded_avg_views_per_video * @conversionRate * @productCost) - @campaignCost) AS net_profit | ||
FROM | ||
ChannelData | ||
|
||
|
||
-- 4. | ||
WHERE | ||
channel_name in ('NoCopyrightSounds', 'DanTDM', 'Dan Rhodes') | ||
|
||
|
||
-- 5. | ||
ORDER BY | ||
net_profit DESC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
# 1. Define variables | ||
# 2. Create a CTE that rounds the average views per video | ||
# 3. Select the columns you need and create calculated columns from existing ones | ||
# 4. Filter results by YouTube channels | ||
# 5. Sort results by net profits (from highest to lowest) | ||
*/ | ||
|
||
|
||
-- 1. | ||
DECLARE @conversionRate FLOAT = 0.02; -- The conversion rate @ 2% | ||
DECLARE @productCost FLOAT = 5.0; -- The product cost @ $5 | ||
DECLARE @campaignCostPerVideo FLOAT = 5000.0; -- The campaign cost per video @ $5,000 | ||
DECLARE @numberOfVideos INT = 11; -- The number of videos (11) | ||
|
||
|
||
-- 2. | ||
WITH ChannelData AS ( | ||
SELECT | ||
channel_name, | ||
total_views, | ||
total_videos, | ||
ROUND((CAST(total_views AS FLOAT) / total_videos), -4) AS rounded_avg_views_per_video | ||
FROM | ||
youtube_db.dbo.view_uk_youtubers_2024 | ||
) | ||
|
||
|
||
-- 3. | ||
SELECT | ||
channel_name, | ||
rounded_avg_views_per_video, | ||
(rounded_avg_views_per_video * @conversionRate) AS potential_units_sold_per_video, | ||
(rounded_avg_views_per_video * @conversionRate * @productCost) AS potential_revenue_per_video, | ||
((rounded_avg_views_per_video * @conversionRate * @productCost) - (@campaignCostPerVideo * @numberOfVideos)) AS net_profit | ||
FROM | ||
ChannelData | ||
|
||
|
||
-- 4. | ||
WHERE | ||
channel_name IN ('GRM Daily', 'Man City', 'YOGSCAST Lewis & Simon ') | ||
|
||
|
||
-- 5. | ||
ORDER BY | ||
net_profit DESC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
# 1. Define variables | ||
# 2. Create a CTE that rounds the average views per video | ||
# 3. Select the columns you need and create calculated columns from existing ones | ||
# 4. Filter results by YouTube channels | ||
# 5. Sort results by net profits (from highest to lowest) | ||
*/ | ||
|
||
|
||
|
||
-- 1. | ||
DECLARE @conversionRate FLOAT = 0.02; -- The conversion rate @ 2% | ||
DECLARE @productCost MONEY = 5.0; -- The product cost @ $5 | ||
DECLARE @campaignCost MONEY = 130000.0; -- The campaign cost @ $130,000 | ||
|
||
|
||
|
||
-- 2. | ||
WITH ChannelData AS ( | ||
SELECT | ||
channel_name, | ||
total_views, | ||
total_videos, | ||
ROUND(CAST(total_views AS FLOAT) / total_videos, -4) AS avg_views_per_video | ||
FROM | ||
youtube_db.dbo.view_uk_youtubers_2024 | ||
) | ||
|
||
|
||
-- 3. | ||
SELECT | ||
channel_name, | ||
avg_views_per_video, | ||
(avg_views_per_video * @conversionRate) AS potential_units_sold_per_video, | ||
(avg_views_per_video * @conversionRate * @productCost) AS potential_revenue_per_video, | ||
(avg_views_per_video * @conversionRate * @productCost) - @campaignCost AS net_profit | ||
FROM | ||
ChannelData | ||
|
||
|
||
-- 4. | ||
WHERE | ||
channel_name IN ('Mister Max', 'DanTDM', 'Dan Rhodes') | ||
|
||
|
||
-- 5. | ||
ORDER BY | ||
net_profit DESC; |