Skip to content

Script Changed #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
231 changes: 87 additions & 144 deletions Shark Tank Analysis Project/SQL Project on Shark Tank India.sql
Original file line number Diff line number Diff line change
@@ -1,144 +1,87 @@
select * from [Shark tank project]..data

-- total episodes

select max( [Ep# No#]) from [Shark tank project]..data
select count(Distinct [Ep# No#]) from [Shark tank project]..data

-- pitches

select count(Distinct [Brand]) from [Shark tank project]..data

--- pitches converted

select cast(sum(a.converted_not_converted) as float) /cast(count(*) as float) from (
select [Amount Invested lakhs] ,case when [Amount Invested lakhs] >0 then 1 else 0 end as converted_not_converted from [Shark tank project]..data) a


--- total male

select sum(male) from [Shark tank project]..data

--- total female

select sum(female) from [Shark tank project]..data


--- gender ratio
select sum(female)/sum(male) from [Shark tank project]..data

--- total invested amount

select sum([Amount Invested lakhs])from [Shark tank project]..data


-- avg equity taken

select avg(a.[Equity Taken %]) from
(select * from [Shark tank project]..data where equitytakenp>0) a



--- highest deal taken


select max([amount invested lakhs]) from [Shark tank project]..data


--higheest equity taken

select max([Equity Taken %]) from [Shark tank project]..data


-- startups having at least women

select sum(a.female_count) startups having at least women from (
select female,case when female>0 then 1 else 0 end as female_count from [Shark tank project]..data) a


-- pitches converted having atleast One women

select * from [Shark tank project]..data

select sum(b.female_count) from(

select case when a.female>0 then 1 else 0 end as female_count ,a.*from (
(select * from [Shark tank project]..data where deal!='No Deal')) a)b


select avg([Team members]) from [shark tank project]..data


--- amount invested per deal

select avg(a.[amount invested lakhs]) amount_invested_per_Deal from
(select * from [Shark tank project]..data where deal!='No Deal')a


-- avg age group of contestants

select avg age,count(avg age) cnt from [Shark tank project]..data group by avg age order by cnt desc


-- location group of contestants

select location,count(location) cnt from [Shark tank project]..data group by location order by cnt desc



-- sector group of contestants

select sector,count(sector) cnt from [Shark tank project]..data group by sector order by cnt desc


--partner deals

select partners,count(partners) cnt from [Shark tank project]..data where partners!='-' group by partners order by cnt desc


-- making the matrix


select * from [Shark tank project]..data

select 'Ashnner' as keyy,count([Ashneer Amount Invested]) from [Shark tank project]..data where [Ashneer Amount Invested] is not null


select 'Ashnner' as keyy,count([ashneer amount invested]) from [Shark tank project]..data where [Ashneer Amount Invested] is not null AND [Ashneer Amount Invested]!=0


SELECT 'Ashneer' as keyy,SUM(C.[ashneer amount invested]),AVG(C.[Aman Equity Taken %])
FROM (SELECT * FROM [Shark tank project]..DATA WHERE [Ashneer Equity Taken %]!=0 AND [Ashneer Equity Taken %] IS NOT NULL) C

select m.keyy,m.total_deals_present,m.total_deals,n.total_amount_invested,n.avg_equity_taken from

(select a.keyy,a.total_deals_present,b.total_deals from(

select 'Ashneer' as keyy,count([Ashneer Amount Invested]) total_deals_present from [Shark tank project]..data where [Ashneer Amount Invested] is not null) a

inner join(
select 'Ashneer' as keyy,count([ashneer amount invested]) total_deals from [Shark tank project]..data
where [Ashneer Amount Invested] is not null AND [Ashneer Amount Invested]!=0)b

on a.keyy=b.keyy) m

inner join

(SELECT 'Ashneer' as keyy,SUM(C.[ashneer amount invested]) total_amount_invested
,AVG(C.[Aman Equity Taken %]) avg_equity_taken
FROM (SELECT * FROM [Shark tank project]..DATA WHERE [Ashneer Equity Taken %]!=0 AND [Ashneer Equity Taken %] IS NOT NULL) C)n

on m.keyy=n.keyy


-- which is the startup in which the highest amount has been invested in each domain/sector




select c.* from
(select brand,sector,[amount invested lakhs],rank() over(partition by sector order by [amount invested lakhs] desc) rnk

from [Shark tank project]..data) c

where c.rnk=1
-- Total episodes
SELECT COUNT(DISTINCT [Ep# No#]) AS total_episodes
FROM [Shark tank project]..data;

-- Pitches
SELECT COUNT(DISTINCT [Brand]) AS total_pitches
FROM [Shark tank project]..data;

-- Pitches converted
SELECT CAST(SUM(CASE WHEN [Amount Invested lakhs] > 0 THEN 1 ELSE 0 END) AS FLOAT) / CAST(COUNT(*) AS FLOAT) AS conversion_rate
FROM [Shark tank project]..data;

-- Total male and female contestants
SELECT SUM(male) AS total_male, SUM(female) AS total_female
FROM [Shark tank project]..data;

-- Gender ratio
SELECT SUM(female) / SUM(male) AS gender_ratio
FROM [Shark tank project]..data;

-- Total invested amount
SELECT SUM([Amount Invested lakhs]) AS total_invested_amount
FROM [Shark tank project]..data;

-- Average equity taken (%)
SELECT AVG([Equity Taken %]) AS avg_equity_taken
FROM [Shark tank project]..data
WHERE [Equity Taken %] > 0;

-- Highest deal amount
SELECT MAX([Amount Invested lakhs]) AS highest_deal_amount
FROM [Shark tank project]..data;

-- Highest equity taken (%)
SELECT MAX([Equity Taken %]) AS highest_equity_taken
FROM [Shark tank project]..data;

-- Startups with at least one woman
SELECT SUM(CASE WHEN female > 0 THEN 1 ELSE 0 END) AS startups_with_women
FROM [Shark tank project]..data;

-- Pitches converted with at least one woman
SELECT SUM(CASE WHEN female > 0 AND deal != 'No Deal' THEN 1 ELSE 0 END) AS pitches_with_women
FROM [Shark tank project]..data;

-- Average team members
SELECT AVG([Team members]) AS avg_team_members
FROM [Shark tank project]..data;

-- Average amount invested per deal
SELECT AVG([Amount Invested lakhs]) AS avg_amount_invested_per_deal
FROM [Shark tank project]..data
WHERE deal != 'No Deal';

-- Average age group of contestants
SELECT AVG([avg age]) AS avg_age, COUNT(*) AS cnt
FROM [Shark tank project]..data
GROUP BY [avg age]
ORDER BY cnt DESC;

-- Location group of contestants
SELECT location, COUNT(location) AS cnt
FROM [Shark tank project]..data
GROUP BY location
ORDER BY cnt DESC;

-- Sector group of contestants
SELECT sector, COUNT(sector) AS cnt
FROM [Shark tank project]..data
GROUP BY sector
ORDER BY cnt DESC;

-- Partner deals
SELECT partners, COUNT(partners) AS cnt
FROM [Shark tank project]..data
WHERE partners != '-'
GROUP BY partners
ORDER BY cnt DESC;

-- Highest amount invested per sector
SELECT brand, sector, [amount invested lakhs]
FROM (
SELECT brand, sector, [amount invested lakhs],
RANK() OVER (PARTITION BY sector ORDER BY [amount invested lakhs] DESC) AS rnk
FROM [Shark tank project]..data
) AS ranked_data
WHERE rnk = 1;