I need follow this Sql server and Mysql
Mysql is better
create table mas
(
id int primary key identity(1,1),
Name varchar(30),
amount1 decimal(18,2)
)
create table trans
(
id int primary key identity(1,1),
NameID int,
amount1 decimal(18,2),
amount2 decimal(18,2),
amount3 decimal(18,2)
)
INSERT INTO MAS VALUES('John',1000.35);
INSERT INTO MAS VALUES('John seena',2000.35);
INSERT INTO MAS VALUES('John wesly',3000.35);
INSERT INTO MAS VALUES('John Gilbert',4000.35);
INSERT INTO MAS VALUES('John sherlok',5000.35);
select * from mas
select * from trans
insert into trans values(1,101,201,301)
insert into trans values(1,111,211,311)
insert into trans values(3,301,401,501)
insert into trans values(5,11,21,31)
insert into trans values(5,21,31,41)
--here i need using left join mas and trans records match or not i need shows records so i use left join
--my query this
SELECT * FROM MAS
SELECT * FROM TRANS
Both Query Not Working... any one fixed this?
--Query need I
SELECT A.ID,NAME,A.AMOUNT1,SUM(B.AMOUNT1)+SUM(B.AMOUNT2)-SUM(B.AMOUNT3)
FROM MAS A LEFT JOIN TRANS B ON A.ID=B.NAMEID
--Query need II
SELECT A.ID,NAME,A.AMOUNT1,SUM(B.AMOUNT1),SUM(B.AMOUNT2),SUM(B.AMOUNT3)
FROM MAS A LEFT JOIN TRANS B ON A.ID=B.NAMEID
Mark as Answer if its helpful to you
Kumaraspcode2009@gmail.com