You need to write an oracle sql query that will allow you to display the range between the dates of operations

Closed due to the fact that off-topic participants Viktorov , Mike , 0xdb , Kromster , cheops 24 Jul '18 at 5:07 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • " Learning tasks are allowed as questions only on condition that you tried to solve them yourself before asking a question . Please edit the question and indicate what caused you difficulties in solving the problem. For example, give the code you wrote, trying to solve the problem "- Viktorov, Mike, 0xdb, Kromster, cheops
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Well, no DDL and at least some attempts to solve it. Would you at least indicate between which operations should be 4 months. - Dmitriy
  • 4 months must be between any operations on one person. - Wanderer
  • Those. Do you want to display people who have windows of at least 4 months in the transaction log? Right? - vp_arth
  • For a more or less adequate request, there are not enough user / transaction identifiers - vp_arth

1 answer 1

To weed out the ranges of the operation they need to somehow get. You can use the join table with itself from youtable join yourtable b . Since you indicated that the operations are for one person, the connection condition is on a."ФИО" = b."ФИО" . In general, it is impossible to do this, instead of the full name, a unique client or personal account code should be used for the connection, but it cannot be seen on your screenshot.

Now we have a sample that iterates over all possible pairs of operations by one full name. To fulfill your condition for 4 months, you can use the MONTHS_BETWEEN function. But see how it calculates the difference in months, whether it will satisfy your requirements or not. The fact is that there are several logical paradoxes when, time ranges are trying to measure in units that do not have a fixed length (year, month).

The final touch to this query. Because There could be a lot of operations passing the condition, and you only need to display the full name, you should add the keyword DISTINCT . It will remove the repetitions of the name in the sample.

 select distinct a."ФИО" from yourtable a join yourtable b on a."ФИО" = b."ФИО" where months_between (a."ДАТА_ОПЕРАЦИИ", b."ДАТА_ОПЕРАЦИИ") > 4 
  • 2
    Good answer to a bad question. - Kromster