Question

How do i add the median height and weight into my SQL at the very end?...

How do i add the median height and weight into my SQL at the very end? I already have a median age but not the other two. everything i do produces a syntax error.

SELECT sum(age) AS "Age Sum",

sum(height) AS "Height Sum",

sum(weight) AS "Weight Sum",

       round(avg(age), 0) AS "Age Average",

              round(avg(height), 0) AS "Height Average",

              round(avg(weight), 0) AS "Weight Average",

       percentile_cont(.5)

       WITHIN GROUP (ORDER BY age) AS "Age Median",

               FROM nfl_player_stats;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

You can use the below SQL query,

SELECT sum(age) AS "Age Sum",

sum(height) AS "Height Sum",

sum(weight) AS "Weight Sum",

       round(avg(age), 0) AS "Age Average",

              round(avg(height), 0) AS "Height Average",

              round(avg(weight), 0) AS "Weight Average",

       percentile_cont(.5)

       WITHIN GROUP (ORDER BY age) AS "Age Median",

(SELECT PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY height) OVER () FROM nfl_player_stats) AS "Height Median",

(SELECT PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY weight) OVER () FROM nfl_player_stats) AS "Weight Median",

               FROM nfl_player_stats;

Add a comment
Know the answer?
Add Answer to:
How do i add the median height and weight into my SQL at the very end?...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In oracle sql, how do I add "not null constraint" at end of create table block...

    In oracle sql, how do I add "not null constraint" at end of create table block and give it a name without using the CHECK constraint? Is it e.g., CONSTRAINT constraintName NOT NULL If so, then how does the statement know which columnName I'm referring to to make NOT NULL? I know that I can do this after declaring the column, what I'm wondering about is how to do this after declaring all the columns.

  • (Using Oracle SQL) How do I find the primary key of this table? And then how...

    (Using Oracle SQL) How do I find the primary key of this table? And then how do I consequently drop the primary key from the table? Edit: I was already give this code and it did not work select constraint_name,constraint_type from user_constraint where table_name='CUSTOMER'; Q7 (10 Points) Use ONE SQL statement to find out the name of the primary key constraint defined on Customer table. (Your SQL should return something like SYS_C0021715, numbers on your account may differ.) Then use...

  • Could anyone help add to my python code? I now need to calculate the mean and...

    Could anyone help add to my python code? I now need to calculate the mean and median. In this programming assignment you are to extend the program you wrote for Number Stats to determine the median and mode of the numbers read from the file. You are to create a program called numstat2.py that reads a series of integer numbers from a file and determines and displays the following: The name of the file. The sum of the numbers. The...

  • The name of my Collection is : People. I am just mentioning the example of data...

    The name of my Collection is : People. I am just mentioning the example of data of people: > db.people.find().limit(1) { "_id" : ObjectId("5d7d87aafed1d209fd0ed58f"), "name" : { "last" : "Keyes", "first" : "Ella", "middle" : "Bella" }, "age" : 43, "gender" : "F", "address" : { "city" : "Lamesa", "state" : "TX" }, "skills" : [ "SQL", "Python", "Perl", "Julia" ] } Could you please help me to solve below questions? 1) Find the number of people in each ten...

  • How do I interpret the p-values in terms of rejecting or failing to reject H0 at...

    How do I interpret the p-values in terms of rejecting or failing to reject H0 at a 95% confidence level? What does the intercept column mean in terms of p-value? How does the p-value of the F test compare and what does it mean? In the simple linear regression I'd conclude age isn't related to pulmonary disease (what does intercept p-value mean) but for the multiple regression I'd say age and height aren't related to pulmonary disease but smoking is...

  • I'm not getting out put what should I do I have 3 text files which is...

    I'm not getting out put what should I do I have 3 text files which is in same folder with main program. I have attached program with it too. please help me with this. ------------------------------------------------------------------------------------ This program will read a group of positive numbers from three files ( not all necessarily the same size), and then calculate the average and median values for each file. Each file should have at least 10 scores. The program will then print all the...

  • First create the two text file given below. Then complete the main that is given. There...

    First create the two text file given below. Then complete the main that is given. There are comments to help you. An output is also given You can assume that the file has numbers in it Create this text file: data.txt (remember blank line at end) Mickey 90 Minnie 85 Goofy 70 Pluto 75 Daisy 63 Donald 80 Create this text file: data0.txt (remember blank line at end) PeterPan 18 Wendy 32 Michael 28 John 21 Nana 12 Main #include...

  • I need help In the lecture you got acquainted with the median algorithm, which calculates the median of an unsorted array with n∈N elements in O (n). But the algorithm can actually do much more: it is...

    I need help In the lecture you got acquainted with the median algorithm, which calculates the median of an unsorted array with n∈N elements in O (n). But the algorithm can actually do much more: it is not limited to finding only the median, but can generally find the ith element with 0≤i <n. Implement this generic version of the median algorithm by creating a class selector in the ads.set2.select package and implementing the following method: /** * Returns the...

  • Put all of your SQL code in a file named grades.sql and submit it below. Download...

    Put all of your SQL code in a file named grades.sql and submit it below. Download the starter code, which contains import_grades.sql and the grades.csv file. Using he import_grades, sql file, create your database and table. - 0 eded. 1 T Une Modify the LOAD DATA INFILE to correct the path to load the grades.csv file, and add/remove LOCAL he only modification you may make to the import_grades.sql or the grades.csv files. The data represents grades for assignments in a...

  • C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) L...

    C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) Last Name (char[]) Age (int) Height in Inches (double) Weight in Pounds (double) You will use pass-by-reference to modify the values of the arguments passed in from the main(). Remember that arrays require no special notation, as they are passed by reference automatically, but the other...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT