Link to home
Start Free TrialLog in
Avatar of Mahmoud Al Jundi
Mahmoud Al JundiFlag for Jordan

asked on

ORACLE QUERY QUESTION

Hello
Have the following 3 tables :

Table One : Jobs
Job No.    Job date
1                10/09/2015
2                11/09/2015

Table Two : Progress

Job No.  Progress_code  Progress Date
1              1                         10/09/2015
1              2                         15/09/2015
1              3                         16/09/2015
2              1                         11/09/2015
2              2                         11/09/2015
2              3                         12/09/2015  

Table Three : Pro_progress

1  Receive
2  Repair
3 Test

Required Query result :

Job No.        Job Date             1-Receive       Days Between Repair and Receive    2-Repair            days betw test/repair          3-Test
1               10/09/2015            10/09/2015                             5                                 15/09/2015                 1                                 16/09/2015
2               11/09/2015            11/09/2015                             0                                 11/09/2015                 1                                 12/09/2015
ASKER CERTIFIED SOLUTION
Avatar of johnsone
johnsone
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mahmoud Al Jundi

ASKER

mmm, becuase I have just posted a sample for Pro_progress, it has more than Receive, Repair,Test....other 20 Records
so Need something Dynamic
Avatar of Sean Stuber
Sean Stuber

>>> so Need something Dynamic

you can't.  
As noted above - SQL doesn't work that way.

If you can use pl/sql and generate a report then ok.  If you're looking for a sql statement then you'll have to specify the 20 fields
Is it truly dynamic?  Could there really be a new status added to the tables without some sort of other significant code change?  It would seem to me that while the number is large, it should be fairly static.  A lengthy query to write, but certainly possible.  What has been posted already is your framework, just keep adding more status codes to it.