PURPOSE Immune checkpoint inhibitors substantially changed advanced non–small-cell lung cancer (aNSCLC) management and can lead to long-term survival. The aims of this study were (1) to use a machine learning method to establish a typology of treatment sequences on patients with aNSCLC who were alive 2 years after initiating a treatment with anti–programmed death-ligand 1 monoclonal antibody nivolumab and (2) to describe the patients' characteristics according to the typology of treatment sequences. MATERIALS AND METHODS This retrospective observational study was based on data from the comprehensive French hospital discharge database for all patients with lung cancer with at least one line of platinum-based chemotherapy, starting nivolumab between January 1, 2015, and December 31, 2016, and alive 2 years after nivolumab treatment initiation. Patients were followed until December 31, 2018. A typology of most common treatment sequences was established using hierarchical clustering with time sequence analysis. RESULTS Two thousand two hundred twelve study patients were, on average, 63.0 years old, 69.9% of them were men, and 61.9% had a nonsquamous cell carcinoma. During the 2 years after nivolumab treatment initiation, clusters of patients with four basic types of treatment sequences were identified: (1) almost continuous nivolumab treatment (44% of patients); (2) nivolumab most of the time followed by a treatment-free interval or a chemotherapy (15% of patients); and a short or medium nivolumab treatment, followed by (3) a long systemic treatment-free interval (17% of patients) or (4) a long chemotherapy (23% of patients). CONCLUSION This machine learning approach enabled the identification of a typology of four representative treatment sequences observed in long-term survival. It was noted that most long-term survivors were treated with nivolumab for well over 1 year.