Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
filter the growth rate for current month
DROP TABLE IF EXISTS Lead; CREATE TABLE Lead(leadId int(11) NOT NULL AUTO_INCREMENT, leadType varchar(99) DEFAULT NULL, leadName varchar(99) DEFAULT NULL, leadDate date DEFAULT NULL, PRIMARY KEY (leadId)); insert into Lead values (15,'corporate','benz','2017-05-10'), (14,'individual','fino','2017-05-05'), (13,'individual','jubin','2017-04-30'), (12,'corporate','chola','2017-06-16'), (10,'corporate','Volvo','2017-03-31'), (9,'individual','manoj','2017-06-16'), (8,'individual','vijay','2017-06-16'), (6,'corporate','CHS','2017-06-16'), (5,'corporate','sastra','2017-06-16'), (4,'individual','rajesh','2017-06-16'), (3,'individual','karthi','2017-06-16'), (2,'individual','vijo','2017-06-16'), (1,'individual','suresh','2017-06-16'); SELECT Year, Month, Entry, IF(@last_entry = 0, 0, ((entry - @last_entry) / entry) * 100) "Growth Rate", @last_entry := entry FROM (SELECT @last_entry := 0) x, (SELECT YEAR(leadDate) Year, MONTH(leadDate) Month, COUNT(*) Entry FROM Lead GROUP BY 1,2) y ; DROP TABLE IF EXISTS Lead;
run
|
edit
|
history
|
help
0
emp
Lanaldiak
sree..
proj
ITM_14210069
emp
gnfgnm
restaurants_menu
admin@pkms99.info
akshay dbms query