I have a payment journal table that is similar to the following:
ClientID Date Amount Category
123 1/2/01 -100 PMT
123 1/5/01 100 NSF
123 1/20/01 -35 PMT
I need to be able to find the first payment from each clientid that does NOT have a corresponding NSF (which will always be Amount *-1). I've tried to do this with a JOIN but I'm not having any luck.
10 1487
Post the query you have made so far. What is the data type of Date column?
Post the query you have made so far. What is the data type of Date column?
The Date is a date type field. The query I have so far looks like: - SELECT a.clientid a.effdt, a.amount, a.category
-
FROM journal a, journal b
-
WHERE a.amount <> (b.amount)*-1
-
SORT BY effdt
Still looking for an answer to this....anyone?
Still looking for an answer to this....anyone?
Try below query: -
SELECT j.* from jnl j where j.caty = 'PMT' AND abs(j.amt) NOT IN (SELECT amt from jnl where caty = 'NSF' and cid = j.cid)
-
This is close to what I need. Here is the issue, if there is one NSF for $160 and then 3 payments for $160, the one NSF will cancel out all three payments.
Is there any easy way to compare them ledger style (compare 1st payment to 1st NSF, if they are the same ignore) and loop until it finds the 1st time when they do not match up.
Is there an easier way to do this? Should I be using some PHP with a more basic query?
This is close to what I need. Here is the issue, if there is one NSF for $160 and then 3 payments for $160, the one NSF will cancel out all three payments.
Is there any easy way to compare them ledger style (compare 1st payment to 1st NSF, if they are the same ignore) and loop until it finds the 1st time when they do not match up.
Is there an easier way to do this? Should I be using some PHP with a more basic query?
Hi,
Does the date for NSF an PMT will be same?
Hi,
Does the date for NSF an PMT will be same?
Try Below Query: -
SELECT E.cid,E.ddate,E.amt,E.caty FROM
-
(SELECT j.*,ROW_NUMBER() OVER(PARTITION BY j.amt,j.caty ORDER BY j.CID) rn FROM jnl j) E
-
WHERE E.rn > 1
-
Hi,
Does the date for NSF an PMT will be same?
No, they would not be the same. An NSF might be within 7-10 days of a PMT.
The problem is, if they pay weekly, there could also be another PMT within that timeframe.
Try Below Query: -
SELECT E.cid,E.ddate,E.amt,E.caty FROM
-
(SELECT j.*,ROW_NUMBER() OVER(PARTITION BY j.amt,j.caty ORDER BY j.CID) rn FROM jnl j) E
-
WHERE E.rn > 1
-
I think I am messing up the syntax somewhere. I'm not familiar with some of the functions you are using, here is what I tried to run:
SELECT e.clientid, e.effdt, e.amount, e.apply_to_category FROM (SELECT j.*, ROW_NUMBER() OVER(PARTITION BY j.amount,j.apply_to_category ORDER BY j.clientid) rn FROM client_journal j) client_journal e WHERE e.rn > 1;
amitpatel - can you give me any help with the syntax? Thanks!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Karen |
last post by:
I inserted this statement and it worked great for the customers that
have no payment history, but for the customers that have a history and
an open invoice, it still used today's date in the mix...
|
by: rahman |
last post by:
I know it should be very easy but I am new in ASP so I could not
figured out.
Here is the simplified version of my code:
thePaymentID= request.querystring("IDValue")
SQLqueryPayment= "SELECT...
|
by: blabla120 |
last post by:
Hi folks,
I am net to NHibernate, and I hava a read baisc/general question.
In my database (PostgreSQL), I have an unique index laying on the field
transaktionsnummer which is located in the...
|
by: davidhumphrey70 |
last post by:
Hi,
I am in serious need of some help PLEASE?
I have a 4 tables (April data, May data, June data and July data) with
numerous fields. Each of the tables has its own "Passed for payment to...
|
by: ghostrider |
last post by:
My program seems to slove for all the mortgages at once. And will not clear out the pane and accept another choice by the user. Can someone steer me in the right direction with this problem. My...
|
by: myemail.an |
last post by:
Hi all,
I am a novice to Access, and was wondering if I could get some help on
a problem I can't solve.
I have a database with customer payments, structured like this:
customer code
type of...
|
by: creative1 |
last post by:
hi,
I am new at writing JSP and Servlets. When I compile my serverlet I get follwoing error
cannot find mymbol method parseDate(java.lang.String)
I have follwoing code:
Code: ( text )...
|
by: TriAdmin |
last post by:
I am shopping for a payment processor for a subscription-based (recurring
payment) website. I need it to be easy to implement and automate the
recurring charges.
I've review the details of...
|
by: Mrs Scilla Madlin |
last post by:
This is to officially inform you that we have verified your contract/inheritance file presently on my desk, and I found out that you
have not fulfilling the obligations giving to you in respect to...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |