473,378 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Accessing data from an intermediate results table

Hi

I'm new to the forum and have a query if someone can help.

I am running on DB2 v7.

I have a master table that holds the current logical date, and another table which holds every day of the year and an indicator to determine if it is a working day (so weekends and bank holidays have this indicator set to 'N', working days are set to 'Y').

The requirement is to initiate a cleardown of other tables in the application based on a parameter defined number of working days in the past. The parameter is held on another table.

I could do this fairly easily by having a cursor that gets all the working day records that are equal to or less than the current logical date and restrict the number of rows fetched, order them in descending date and read through to the end.

However I was trying to get the data into an intermediate table and then get the lowest date using the MIN function. As soon as I bracket the sub query the syntax checker throws out the ORDER BY.

I have the following example that uses arbitrary date ranges. I have gone back 62 days to make sure that I am picking up 30 working days (which is likely to be our clear down limit)

--SELECT MIN(X.PROCESSING_DT)
--FROM (
SELECT A.PROCESSING_DT
FROM TBM004_WORKDYS A
,TBM020_MASTER B
WHERE A.PROCESSING_DT > DATE(DAYS(B.PROCESSING_DT)-62)
AND A.PROCESSING_DT <= B.PROCESSING_DT
AND A.WORK_DAY_IND = 'Y'
ORDER BY A.PROCESSING_DT DESC
FETCH FIRST 30 ROWS ONLY
--) AS X
Jun 19 '07 #1
0 1029

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing/modifying the code. Thank you. .. Facundo
0
by: Damodar Periwal | last post by:
---------------------------------------------------------------- OneClickRevelation(tm) JDX Provides Instant and Interactive Insight Into Your Data...
0
by: Damodar Periwal | last post by:
---------------------------------------------------------------- OneClickRevelation(tm) JDX Provides Instant and Interactive Insight Into Your Data...
4
by: Mullin Yu | last post by:
i have a stored procedure at sql server 2k. which will update records and select result from temp table. if i use SqlConnection class, and i do both. but, if i use OleDbConnection class, i can...
10
by: tshad | last post by:
I have a dropdownbox object: <asp:DropDownList ID="ddlQuestionType" runat="server"> <asp:ListItem Value="MS" Text="Multiple Single" /> <asp:ListItem Value="MM" Text="Multiple Multiple" />...
2
by: contractsup | last post by:
Environment: $ uname -a AIX <withheld2 5 000100614C00 $ db2level DB21085I Instance "<withheld>" uses "32" bits and DB2 code release "SQL08024" with level identifier "03050106"....
4
by: Ronald S. Cook | last post by:
We're designing the data model for a project. The app will be in .NET, the database will be in SQL Server 2005. I'm a little confused on type conversion between the two and which I should...
19
by: cj | last post by:
I'm getting terrible response times trying to pull data from VFP tables using .net--like 2 minutes! Can someone help? f:\arcust01 currently contains 187,728 records and is indexed on CUSTNO...
8
by: GaryDean | last post by:
I have a Wizard page and need to affect the next and previous buttons from my code-behind. I've googled around and found two solutions, and neither appear to work. I can access the SideBarList...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
1
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...
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.