Saturday, 7 January 2012

procedure for Searching with month and year only


see bold code for u r need

CREATE DEFINER=`root`@`localhost` PROCEDURE `P_GET_District_Transactions`(
 in month1 int,
 in year1 int,
 in month2 int,
 in year2 int
 )
BEGIN
 select mc.dist_no as "District No1",
 md.dist_name as "District Name1",
 sum(tm.no_txns)as "Total Transactions1",
 sum(tm.Income)as "Income1",
 sum(tm.amount)as "Amount Collected1"
 from txn tm
 join mst_center mc on tm.center_code=mc.center_code
 join mst_dist md on mc.dist_no=md.dist_no
 where (cast(concat(tm.year,'-',tm.month,'-','01') as date) between cast(concat(year1,'-',month1,'-',01)as date) and cast(concat(year2,'-',month2,'-',01)as date)) 
 group by(mc.dist_no);

No comments:

Post a Comment