Skip to Content

SQL query to find last airline that has been used twice

I'm pretty new to SAP and HANA Development. I use Eclipse and work with HANA Systems. I have a Calculation View. In this view I have 3 columns: CUSTOMER, AIRLINE, FLIGHT_DATE.

This could be some example data:

What I'm trying to do: find out with which airline a customer flew lastly twice. In this case it should pick airline 5 for customer 1.

Last flights: 7 - 5 - 9 - 5 - 9. Airline 5 was the one with which customer 1 flew lastly twice.

Has anyone an idea how to implement that rule with rank function, calculated column or something like that?

unbenannt.png (3.8 kB)
Add comment
10|10000 characters needed characters exceeded

  • Welcome to HANA development and this community forum.

    Just like in most other forums, we don't accept 'requirement dumping' but instead offer help to help yourself.

    What have you tried so far to solve your problem? Show us your code for that.

    Also, what should be the output if customers used an airline more than twice?

    Should customers without multiple flights with a specific airline be part of the result at all?

    You'll notice that I edited the question title and tags for you - please try and be specific with your title and use the most relevant tag for your primary tag.

  • Get RSS Feed

0 Answers