A Query Which Looks Ahead.... [message #298504] |
Wed, 06 February 2008 04:33  |
CocoPop
Messages: 12 Registered: August 2007 Location: England
|
Junior Member |
|
|
Hi,
I have a table of work, for each row there is a frequency column, and this is the number of days this work is repeated
i.e. if it was 24 every 24 days the work woruld be carried out
I need to write a query which can return a row for each time the work is to be carried out in the space of the next year
Is this possible??
Thanks
|
|
|
|
Re: A Query Which Looks Ahead.... [message #298520 is a reply to message #298504] |
Wed, 06 February 2008 04:53   |
CocoPop
Messages: 12 Registered: August 2007 Location: England
|
Junior Member |
|
|
Ok, I have created a simple script to create and populate a simple table to explain what I mean (Please se the attached Script)
So the table has 10 rows, each row has a different frequency, for eaxmple WorkId 4 has a frequency of 28
So every 28 days this work would need to be carried out, and so in my look ahead query of one year this Work ID and Description would need to be printed 15 times.
Create table LookAhead(WorkId int, Description Char(100), Frequency int)
Insert into LookAhead (WORKID, DESCRIPTION, FREQUENCY) Values (1, 'Description 1', 25);
Insert into LookAhead (WORKID, DESCRIPTION, FREQUENCY) Values (2, 'Description 2', 26);
Insert into LookAhead (WORKID, DESCRIPTION, FREQUENCY) Values (3, 'Description 3', 27);
Insert into LookAhead (WORKID, DESCRIPTION, FREQUENCY) Values (4, 'Description 4', 28);
Insert into LookAhead (WORKID, DESCRIPTION, FREQUENCY) Values (5, 'Description 5', 29);
Insert into LookAhead (WORKID, DESCRIPTION, FREQUENCY) Values (6, 'Description 6', 30);
Insert into LookAhead (WORKID, DESCRIPTION, FREQUENCY) Values (7, 'Description 7', 31);
Insert into LookAhead (WORKID, DESCRIPTION, FREQUENCY) Values (8, 'Description 8', 32);
Insert into LookAhead (WORKID, DESCRIPTION, FREQUENCY) Values (9, 'Description 9', 33);
Insert into LookAhead (WORKID, DESCRIPTION, FREQUENCY) Values (10, 'Description 10', 34);
COMMIT;
[Edit: Included the File content and added the CODE tag by Raj ]
[Edit: Remove 80 useless spaces in strings by MC]
regards
-
Attachment: Script.sql
(Size: 1.90KB, Downloaded 467 times)
[Updated on: Wed, 06 February 2008 05:22] by Moderator Report message to a moderator
|
|
|
|
|
Re: A Query Which Looks Ahead.... [message #298534 is a reply to message #298504] |
Wed, 06 February 2008 05:28   |
mshrkshl
Messages: 247 Registered: September 2006 Location: New Delhi
|
Senior Member |
|
|
Quote: | I need to write a query which can return a row for each time the work is to be carried out in the space of the next year
|
may you define it by a test case?
regards,
|
|
|
|
|
|
|
|
|
|
|
Re: A Query Which Looks Ahead.... [message #298770 is a reply to message #298707] |
Thu, 07 February 2008 11:09  |
 |
Michel Cadot
Messages: 68733 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
1/ please read and follow OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code.
Use the "Preview Message" button to verify.
2/ Don't give solution in newbie forum, just give hint/clue/way to find a solution
Regards
Michel
|
|
|