Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Link to table with value from calculation

Status
Not open for further replies.

WondersWhy

Technical User
Nov 18, 2001
13
0
0
US
Hi,

I need to know a SQL statement trick that would identify a record in a table with the value of a a calculation. Can this be done?

I have a calendar table that defines for a given date what accounting period the date falls under and whether it is a working day or not as well as give a unique working day number for each working day.

I would like to pull the "working_day_number" for a date, subtract a few days from that and with the result, point back to the table (an alias of course) and find out what the resulting date is.

Any ideas?

Thanks a bunch!
Tony T.
 
Select t.*
from Table t
where working_day_number=(Select working_day_number - x as working_day_number
from Table
where something)

I think this should get you what you need.

Michael
 
Thanks Michael,
I am a bit of a novice with SQL queries, but this looks simple enough for even me to understand and I do not see why this wouldn't work (at least logically). Unfortunately, I may need to find another way to do this. I am using Cognos Impromptu which has a SQL statement generating wizard so to speak. I cannot find SELECT as one of my options and the wizard doesn't let me simply type it in. I wonder if the available option called "lookup" is equivalent???
Tony.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top