Created
January 11, 2014 16:37
-
-
Save doron2402/8373176 to your computer and use it in GitHub Desktop.
Interview question for Mysql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Answer : http://sqlfiddle.com/#!2/843f41/32