[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Analytical functions in db2

Posted on 2014-08-26
Medium Priority
Last Modified: 2014-09-12
A table has accountnumbers, status codes and effective dates. I need to get accountnumbers, status codes and effdates which has statuscode = ' 5' and also statuscode ='F' or statuscode = 's' before having statuscode = '5'. These account numbers should have had statuscode= 'F' or statuscode = 's' before statuscode = '5'.

What is the best way to write the query. Please suggest
Question by:d27m11y
LVL 37

Accepted Solution

momi_sabag earned 2000 total points
ID: 40286101
Select account number, effdate
From table1 p
Where status code='5'
And exists (select 1 from table1
   Where accountnumber = p.account number and effdate < p.effdate and status code in ('f', 's'))
LVL 27

Expert Comment

ID: 40289758
It makes no sense to say "which has statuscode = ' 5' and also statuscode ='F'" nor to say "statuscode = 's' before having statuscode = '5'". Much more detail is needed.


Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question