TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Devendra Kumar
NA
500
163.4k
Sql query to find the customer having due amount
Jul 23 2017 4:06 PM
It was a billing application and I got stuck to get the output
Requirement:
I want to get which customerID has due amount on which InvoiceNo by what amount
as CustomerID 1 having total Bill Amount 1000 and had paid 1000 (200+100+700) as AdvanceAmount, that means Invoice 1 is totally paid, and hence customerID 1 is having a due amount of 10000.
I cannot able to write the query for the above problem.
Output should be the row having InvoiceNo2 with due amount 10000.
Here's Table structure
CREATE TABLE [dbo].[AdvancePayment](
[ID] [bigint] IDENTITY(1,1) NOT NULL,
[Date] [date] NULL,
[CustomerID] [nvarchar](max) NULL,
[InvoiceNo] [nvarchar](max) NULL,
[BillAmt] [
decimal
](18, 2) NULL,
[AdvanceAmount] [
decimal
](18, 2) NULL,
[Status] [nvarchar](50) NULL,
[CreatedBy] [nvarchar](max) NULL,
CONSTRAINT [PK_AdvancePayment] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
Reply
Answers (
2
)
What are scheduled tasks in SQL Server?
Generate three rows dynamically based on data