Hi
I need MySql Query Issue (Most Urgent) any one guide me.
this is table with sample Data.
CREATE TABLE `test`.`mas` (
`id` INT NOT NULL AUTO_INCREMENT ,
`Name` VARCHAR(45) NULL ,
`Balance` DECIMAL(18,2) NULL ,
`EmpNo` INT NULL ,
PRIMARY KEY (`id`) );
CREATE TABLE `test`.`trans` (
`id` INT NOT NULL AUTO_INCREMENT ,
`EmpNo` INT NULL ,
`Recept` DECIMAL(18,2) NULL ,
`Payment` DECIMAL(18,2) NULL ,
`Status` VARCHAR(45) NULL ,
`Date` DATE NULL ,
PRIMARY KEY (`id`) );
INSERT INTO `test`.`mas` (`Name`, `Balance`, `EmpNo`) VALUES ('John', '1500', 1001);
INSERT INTO `test`.`mas` (`Name`, `Balance`, `EmpNo`) VALUES ('Wesley', '2500', 1002);
INSERT INTO `test`.`mas` (`Name`, `Balance`, `EmpNo`) VALUES ('Kilbert', '3500', 1003);
INSERT INTO `test`.`mas` (`Name`, `Balance`, `EmpNo`) VALUES ('Rajas', '4500', 1004);
INSERT INTO `test`.`trans` (`EmpNo`, `Recept`, `Payment`, `Status`, `Date`) VALUES (1001, '120', '130', 'ACTIVE', '2015-02-01');
INSERT INTO `test`.`trans` (`EmpNo`, `Recept`, `Payment`, `Status`, `Date`) VALUES (1001, '130', '150', 'REJECT', '2015-04-04');
INSERT INTO `test`.`trans` (`EmpNo`, `Recept`, `Payment`, `Status`, `Date`) VALUES (1001, '180', '140', 'ACTIVE', '2015-06-06');
INSERT INTO `test`.`trans` (`EmpNo`, `Recept`, `Payment`, `Status`, `Date`) VALUES (1002, '250', '250', 'ACTIVE', '2015-03-03');
INSERT INTO `test`.`trans` (`EmpNo`, `Recept`, `Payment`, `Status`, `Date`) VALUES (1004, '320', '321', 'REJECT', '2015-04-04');
I need Following Condition Output.
1.Need Left Join mas and trans table for match or not in empno
2.when the record mas and trans presence i need check status active records only shown.
3.opening balance calculation like this
before from date which we entered sum following field mas table Balance+Recept-Payment.
Mark as Answer if its helpful to you
Kumaraspcode2009@gmail.com