Date-Based Summaries : DATE « Date Time « SQL / MySQL






Date-Based Summaries

    
mysql>
mysql>
mysql> CREATE TABLE Master (
    ->   LahmanID char(10) NOT NULL default '',
    ->   Lastname char(25) default NULL,
    ->   Firstname char(25) default NULL,
    ->   Bats char(1) default NULL,
    ->   Throws char(1) default NULL,
    ->   BirthMonth int(11) default NULL,
    ->   BirthDay int(11) default NULL,
    ->   BirthYear int(11) default NULL,
    ->   Debut int(11) default NULL,
    ->   PRIMARY KEY  (LahmanID)
    -> ) TYPE=MyISAM;
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql>
mysql> SELECT birthmonth, birthday, COUNT(*)
    -> FROM master
    -> WHERE birthmonth IS NOT NULL AND birthday IS NOT NULL
    -> GROUP BY birthmonth, birthday;
Empty set (0.00 sec)

mysql>
mysql> drop table master;
Query OK, 0 rows affected (0.00 sec)

mysql>

   
    
    
    
  








Related examples in the same category

1.Extract just the date: DATE()
2.Treating Dates or Times as Numbers
3.Synthesizing Dates or Times Using Formatting Functions
4.Synthesizing Dates or Times Using Component-Extraction Functions
5.Date-Based Sorting
6.Add an incorrect date to a special table and show the result.