Hi smile,
Please refer below sample query.
SQL
CREATE TABLE [Students]
(
[ID] [int] NOT NULL,
[Type] [varchar](50) NULL,
[Amount] [int] NULL
)
GO
INSERT [Students] ([ID], [Type], [Amount]) VALUES (1, N'Payment', 2000)
INSERT [Students] ([ID], [Type], [Amount]) VALUES (2, N'Receipt', 1000)
INSERT [Students] ([ID], [Type], [Amount]) VALUES (3, N'Payment', 3000)
INSERT [Students] ([ID], [Type], [Amount]) VALUES (4, N'Receipt', 2000)
INSERT [Students] ([ID], [Type], [Amount]) VALUES (5, N'Payment', 1000)
GO
SELECT (SELECT SUM(Amount) AS Total
FROM Students
WHERE [Type] = 'Payment')
-
(SELECT SUM(Amount) AS Total
FROM Students
WHERE [Type] = 'Receipt') AS 'Balance'
Output
Balance
3000