Skip to main content

SQL Journey: Blog #3

I have reached the end of lesson 2. The final project is entitled "Data dig" where we are given a set of interesting 

data sets: NASA astronauts, Superbowl results, Pokemon stats, NBA players, Top movies, Top countries by population, Solar system objects by size, Marvel characters, Furniture store sales, Earned KA badges, Winston's donut logs, Card game results, and NFL draft picks.

We are to pick one of those data sets and use advanced SELECT queries to discover things about the data. What sort of questions might one have about that data, like if they were using it for an app or a business idea? Here are some ideas:What are average, max, and min values in the data?
What about those numbers per category in the data (using HAVING)?
What ways are there to group the data values that don’t exist yet (using CASE)?
What interesting ways are there to filter the data (using AND/OR)?

Basically, the above given questions will serve as a guide on what we could dig from the given data set. Since these are generic questions that will serve as guide, we will deal with it later. For now, let us select what data set we shall use. I chose Top movies. Given below is the database schema.

topmovies100 rows
RankINTEGER
TitleTEXT
StudioTEXT
WorldwideREAL
DomesticREAL
DomesticPctREAL
OverseasREAL
OverseasPctREAL
YearINTEGER
If I have this dataset, the first question I could possibly ask is, "How much is the maximum and minimum worldwide box office earnings for movies that belong to the top 100?" Here, we could use the following code to get the value:

SELECT title, MAX(Worldwide) FROM topmovies;
SELECT title, MIN(Worldwide) FROM topmovies;

QUERY RESULTS

TitleMax(Worldwide)
Avatar2788
TitleMIN(Worldwide)
Tangled591.8

The next question I could possibly ask is, "How much is the average worldwide, average domestic, and average overseas gross revenue for the top 100 movies?" Here, we could use the following code to get the value:

SELECT title, ROUND(AVG(Worldwide)) AS avg_worldwide, ROUND(AVG(Domestic)) AS avg_domestic, ROUND(AVG(Overseas)) AS avg_overseas FROM topmovies;

By doing this, up and coming movies will be able to assess whether they are below, equal, or above the worldwide, domestic, and overseas average gross revenues. 

QUERY RESULTS

avg_worldwideavg_domesticavg_overseas
863307555
For example, for the movie, "The Greatest Showman" which I liked watching, its worldwide box office is $430.58 million, domestic box office is $174.34 million, and overseas box office is $256.24 million. All these values are below the calculated averages.

Another thing, I could ask is, "How many movies were included in the top 100 movies when grouped by studio? Which among the studios have the highest number of count and the lowest number of count?" Here, we could use the following code to get the value:

SELECT Studio, COUNT(*) FROM topmovies GROUP BY Studio ORDER BY COUNT(*);

SELECT Studio, COUNT(*) FROM topmovies GROUP BY Studio HAVING COUNT(*) = 23;

SELECT Studio, COUNT(*) FROM topmovies GROUP BY Studio HAVING COUNT(*) = 1;

QUERY RESULTS


StudioCOUNT(*)
DW1
LG/S1
NM1
LGF3
NL3
Sum.3
Par.7
Uni.8
P/DW9
Sony11
Fox13
WB17
BV23
StudioCOUNT(*)
BV23
StudioCOUNT(*)
DW1
LG/S1
NM1

Another question would be, "How much is the average worldwide box office revenue when grouped by studio?" Here, we could use the following code to get the value:

SELECT Studio, ROUND(AVG(Worldwide)) AS avg_worldwide FROM topmovies GROUP BY Studio ORDER BY avg_worldwide;

QUERY RESULTS

Studioavg_worldwide
NM612
Sum.707
P/DW763
Sony768
LGF769
LG/S830
Uni.845
BV871
DW920
WB923
Fox924
Par.962
NL972

Comments

Popular posts from this blog

Privacy Policy of ShinStats: descriptives calc

Privacy Policy Shin Nix built the ShinStats app as an Ad Supported app. This SERVICE is provided by Shin Nix at no cost and is intended for use as is. This page is used to inform visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service. If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy. The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which are accessible at ShinStats unless otherwise defined in this Privacy Policy. Information Collection and Use For a better experience, while using our Service, I may require you to provide us with certain personally identifiable information. The information that I request will be retaine...

Gears Update

It has been a while since my last post and many things have happened since then. For one, I decided to upgrade my laptop as I saw it fit for the direction I am moving towards particularly on data analytics. It's been almost 10 years since I bought "Julian", my first work laptop, and there were so many milestones that we shared together. I bought my first laptop during my second job in Taguig City. It served as an extension of myself as I work to earn for my family particularly in helping my siblings with their education as I am the eldest and breadwinner of the family. That laptop was able to create a joint personnel reporting system excel file which was used by the Philippine Army to be able to account their personnel on a national level during my stint as an Engineer / Researcher in the aforementioned organization. Julian was my laptop when I finished my Master's degree at the Ateneo de Davao University where I also created the Programmable Logic Controller Trainer ...

Could this be my first...?

What's up Nixers! In today's blog, I want to discuss with you the things that I did these past two weeks. After my encounter with my colleague, Adonis, one of our discussions focused on the creation of an app that would help ease students' struggles. He was very passionate about an app for a civil engineering application involving beams under load. As our discussions went on, I do acknowledge that if that particular app would be realized, it would really benefit civil engineering students in a profound way. What I liked about the discussion was how the app was described. Like, if I put my self in the user's perspective, the user interface which he discussed would be "user-friendly" as he really understands the flow of how things are to be calculated. As we left and went each other's ways, I was inspired by an idea to create an app utilizing the python programs that I have already developed for statistics. Like, how useful would it be for students to guide ...