Skip to content

Instantly share code, notes, and snippets.

@doron2402
Created January 11, 2014 16:37
Show Gist options
  • Save doron2402/8373176 to your computer and use it in GitHub Desktop.
Save doron2402/8373176 to your computer and use it in GitHub Desktop.
Interview question for Mysql
CREATE TABLE `payments` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`amount` DECIMAL(8,2) NOT NULL,
`date` DATE NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
INSERT INTO `payments` (`amount`,`date`) VALUES ('3.44','2012-01-01');
INSERT INTO `payments` (`amount`,`date`) VALUES ('344','2012-02-01');
INSERT INTO `payments` (`amount`,`date`) VALUES ('66.48','2012-03-01');
INSERT INTO `payments` (`amount`,`date`) VALUES ('111','2012-04-01');
- Generate a table that will look like this
Date Amount
2012-01-01 3.44
2012-02-01 3.44 + 344
...
@doron2402
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment