MySQL Forums
Forum List  »  Newbie

Query on a table
Posted by: michael ponds
Date: August 14, 2014 11:48PM

Hi there, i have been scratching my head on this one fore a while, i can figure out how to do it with 7 commands, but i would like to know how to do it in one.

So here is the schema(?) for the table;
last_name VARCHAR(15) NOT NULL,
first_name VARCHAR(15) NOT NULL,
suffix VARCHAR(5) NULL,
city VARCHAR(20) NOT NULL,
state VARCHAR(2) NOT NULL,
birth DATE NOT NULL,
death DATE NULL
The data i have inserted in the table is all 43 of america's past and current presidents.
i would like to know how to query the following; " If you became president, which day are you least likely to die on?"
I can easily run the query with seven different commands of the form;
select count(*) from president where dayofweek(death)=1
and then just cycle dayofweek(death) from 1 to 7 and find the lowest return, but im stuck for finding one command to do it. Thank you!

Options: ReplyQuote


Subject
Written By
Posted
Query on a table
August 14, 2014 11:48PM
August 15, 2014 04:48AM
August 19, 2014 12:56AM
August 19, 2014 05:35AM


Sorry, you can't reply to this topic. It has been closed.
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.