The Detroit Pistons did a lot of losing this season, finishing with the second-worst record in the NBA and the franchise's worst record in nearly 30 years.

It paid off.

The Pistons won the NBA draft lottery on Tuesday night, grabbing the No. 1 pick in the July 29 draft and presumably the chance to select Oklahoma State guard Cade Cunningham. If the Pistons keep the pick, it'll be the first time they select No. 1 overall since taking Bob Lanier in 1970.

Houston will pick second, Cleveland will pick third, and Toronto will pick fourth. Orlando will get the No. 5 and No. 8 selections, with Oklahoma City picking No. 6 and Golden State also with two lottery slots - No. 7, as part of a trade with Minnesota, and the Warriors' own pick at No. 14.

The rest of the lottery results: Sacramento picks No. 9, New Orleans No. 10, Charlotte No. 11, San Antonio at No. 12, and Indiana at No. 13.

The Raptors, who had the seventh best chance at winning the lottery, had a rough season. Forced to play out of Tampa, Fla., due to COVID-19 travel restrictions, and hit hard by an outbreak of the virus in March, they finished 27-45 and 12th in the Eastern Conference.

They had a 7.5% chance of landing the No. 1 pick. Point guard Fred VanVleet represented Toronto - virtually - at the event.

The Raptors have had the No. 4 pick twice before. In 1998, they picked Antawn Jamison and traded to Golden State for Vince Carter, who went No. 5. And in 2003, they selected Chris Bosh.

The lottery - 14 ping-pong balls, all numbered 1 through 14, placed into a hopper - technically only determines the first four picks. The rest then default to a pre-established order of finish; Golden State, for example, had only a 2.4% chance of its own pick being anything other than the No. 14 selection.

And form held through the first six picks that were unveiled. The No. 8 pick, which was slotted to go to Chicago, winds up with the Magic as part of the Nikola Vucevic trade from this season. That's when the first significant buck-the-odds move happened, when Toronto's 31.9% chance of cashing into a top-four slot delivered.

The Thunder will have three first-round picks, but none higher than No. 6.

The Rockets had a 52% chance of winning a top-four pick - which meant it was basically even money.

The worst Houston could do was the No. 5 selection, and that truly was a worst-case scenario because if the Rockets were outside of the top four the pick would convey to Oklahoma City as part of the compensation for the Russell Westbrook trade between those teams in 2019.

But they held on, getting the No. 2 pick as one of the building blocks they can use to reload after finishing with the NBA's worst record this season.

The consensus opinion has been that the No. 1 pick will be either a one-and-done college player - Cunningham, Southern California center Evan Mosley or Gonzaga guard Jalen Suggs - or someone from the G-League development program like guard Jalen Green or forward Jonathan Kuminga.

And, as always, it'll be a guessing game: Most of the players expected to be lottery picks are teenagers, mostly 19, some 18.

The rest of the first round, for now, is slotted this way - Washington will pick 15th, followed by Oklahoma City, Memphis, Oklahoma City, New York, Atlanta, New York, the Los Angeles Lakers, then Houston at both No. 23 and No. 24, followed by the Los Angeles Clippers, Denver, Brooklyn, Philadelphia, Phoenix and Utah.