Home » SQL & PL/SQL » SQL & PL/SQL » How to get the right information suggested about Date
How to get the right information suggested about Date [message #636868] Mon, 04 May 2015 11:18 Go to next message
sbouhila
Messages: 7
Registered: May 2015
Location: Morocco
Junior Member
I'm trying through this sql query to retrieve rows in accordance with those restrictions:
The date of the Proprietaire column must be less than or equal to the date of Statut column, knowing that both of them are joined to the same Table Audit_Log; from where they get the information about the right time where the change of date occurred.

I need to enhance this query in order to get what i want and if someone has an other suggestion for me, it will be a pleasure for me.

tried query :
SELECT ONE.ID, ONE.Num_QC_EDF, ONE.Statut, TWO.Proprietaire, ONE.ChangeDate
FROM
    (SELECT B.BG_BUG_ID as ID, B.BG_USER_15 as Num_QC_EDF
         ,AP.AP_NEW_VALUE as Statut, AL.AU_TIME as ChangeDate
     FROM  BUG B
     INNER JOIN AUDIT_LOG AL ON AL.AU_ENTITY_ID = B.BG_BUG_ID    
     INNER JOIN AUDIT_PROPERTIES AP ON AL.AU_ACTION_ID = AP.AP_ACTION_ID
         AND AL.AU_ENTITY_TYPE = 'BUG'
         AND AL.AU_ACTION_ID= AP.AP_ACTION_ID
         AND AP_FIELD_NAME= 'BG_STATUS'
         AND AP_NEW_VALUE= 'TU leger OK')ONE,
    (SELECT B.BG_BUG_ID as ID, B.BG_USER_15 as Num_QC_EDF, 
         AP.AP_NEW_VALUE as Proprietaire, AL.AU_TIME as ChangeDate
     FROM  BUG B
     INNER JOIN AUDIT_LOG AL ON AL.AU_ENTITY_ID = B.BG_BUG_ID
     INNER JOIN AUDIT_PROPERTIES AP ON AL.AU_ACTION_ID = AP.AP_ACTION_ID
         AND AL.AU_ENTITY_TYPE = 'BUG'
         AND AL.AU_ACTION_ID= AP.AP_ACTION_ID
         AND AP.AP_FIELD_NAME = 'BG_RESPONSIBLE')TWO,
BUG B
WHERE ONE.ID= TWO.ID AND TWO.ID= B.BG_BUG_ID 
    AND ONE.Num_QC_EDF= TWO.Num_QC_EDF AND TWO.Num_QC_EDF= B.BG_USER_15 
    AND TWO.ChangeDate <= ONE.ChangeDate
ORDER BY BG_BUG_ID, BG_USER_15   :(  


*BlackSwan added {code} tags. Please do so yourself in the future.

[Updated on: Mon, 04 May 2015 11:22] by Moderator

Report message to a moderator

Re: How to get the right information suggested about Date [message #636869 is a reply to message #636868] Mon, 04 May 2015 11:21 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Welcome to this forum.

Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/ and read http://www.orafaq.com/forum/t/174502/


We don't know your tables or data.
We don't know what the correct result set should contain.
Re: How to get the right information suggested about Date [message #636870 is a reply to message #636868] Mon, 04 May 2015 11:51 Go to previous messageGo to next message
sbouhila
Messages: 7
Registered: May 2015
Location: Morocco
Junior Member
Below are tables describing the utility of each column name which can help you to understand the query i suggested to enhance.
/forum/fa/12653/0/
  • Attachment: p1.PNG
    (Size: 30.23KB, Downloaded 1175 times)

[Updated on: Mon, 04 May 2015 11:52]

Report message to a moderator

Re: How to get the right information suggested about Date [message #636871 is a reply to message #636870] Mon, 04 May 2015 11:52 Go to previous messageGo to next message
sbouhila
Messages: 7
Registered: May 2015
Location: Morocco
Junior Member
/forum/fa/12654/0/
  • Attachment: p2.PNG
    (Size: 40.30KB, Downloaded 1325 times)
Re: How to get the right information suggested about Date [message #636872 is a reply to message #636871] Mon, 04 May 2015 11:54 Go to previous messageGo to next message
sbouhila
Messages: 7
Registered: May 2015
Location: Morocco
Junior Member
This image shows the relationship between tables:
/forum/fa/12655/0/
  • Attachment: p3.PNG
    (Size: 15.07KB, Downloaded 1137 times)
Re: How to get the right information suggested about Date [message #636873 is a reply to message #636872] Mon, 04 May 2015 12:15 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
post test case.

We don't know what the correct result set should contain.
Re: How to get the right information suggested about Date [message #636919 is a reply to message #636873] Tue, 05 May 2015 10:47 Go to previous messageGo to next message
sbouhila
Messages: 7
Registered: May 2015
Location: Morocco
Junior Member
To be clear, the query consists of using the field 'AL.AU_TIME' (which return the date when the change occured ) twice.
Once, to retrieve the changedate of the status and twice for the changedate of Proprietaire column which must be less than or equal to the first changedate returned by the query.
Still waiting for help Sad
Re: How to get the right information suggested about Date [message #636921 is a reply to message #636919] Tue, 05 May 2015 11:02 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Explain with words what should the result set.
This should start with "it is the set of rows which satisfy...".

Re: How to get the right information suggested about Date [message #636923 is a reply to message #636921] Tue, 05 May 2015 11:47 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
We still don't know what the correct result set should contain or why.
Re: How to get the right information suggested about Date [message #636924 is a reply to message #636923] Tue, 05 May 2015 12:01 Go to previous messageGo to next message
sbouhila
Messages: 7
Registered: May 2015
Location: Morocco
Junior Member
i sent to you in a private message two pictures about the result obtained and the once expected .
This query is performed in hp alm and allows to know the name of the person who does effectivly the defect change. The name is entered in Proprietaire column and the change of it can happen only before the change of the status column . That's why the restriction in the date of Proprietaire must be less than or equal to status date one when retrieving data .
Re: How to get the right information suggested about Date [message #636925 is a reply to message #636924] Tue, 05 May 2015 12:56 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

No image can answer my question.
I want words.

Re: How to get the right information suggested about Date [message #636940 is a reply to message #636925] Wed, 06 May 2015 04:07 Go to previous message
sbouhila
Messages: 7
Registered: May 2015
Location: Morocco
Junior Member
I sent in image the set of rows expected from the query.
Well, the set of rows returned must respect those restrictions:
the column Proprietaire must contain data whose changedate is less than or equal to changedate of status column . This is my issue with the query.
How can i do this comparison while both columns ( Proprietaire and status) refer to same column AU_TIME from AUDIT_LOG table to get the changedate ???
I think now my question is very clear .
Previous Topic: How to convert CLOB(results of an SQL query) to XMLDocument
Next Topic: PL/SQL: ORA-00980: synonym translation is no longer valid
Goto Forum:
  


Current Time: Thu Apr 25 15:23:30 CDT 2024