LOS ANGELES (AP) _ NBC's summer bandwagon, with Bill Cosby at the reins, rolled to another victory in the Nielsen ratings for the week ended June 30.

It was the sixth straight triumph for NBC, which emerged this past season from nine months in the ratings cellar. CBS was second for the week and ABC was third.

NBC ended the past television season in April second to first-place CBS, with ABC coming in third, but since then the network has been on a tear.

''The Cosby Show'' was first and NBC's ''Family Ties'' and the movie ''Code of Vengeance'' tied for second. The movie has been likened by some reviewers to ''Rambo.'' That's a comparison NBC didn't mind at all, since ''Rambo: First Blood Part II'' is this summer's box office champion. But it's really more of a modern version of ''Shane,'' in which the mysterious stranger comes to town, is befriended by the widow and her young son and proceeds to clean up the town.

NBC had six programs in the Top 10, CBS had three and ABC one.

CBS' ''Cagney & Lacey'' was fourth; CBS' ''Newhart,'' fifth; NBC's ''Cheers,'' sixth; CBS' ''Kate & Allie'' and NBC's ''Miami Vice,'' tied for seventh; ABC's ''20-20,'' ninth; and NBC's ''Night Court,'' tenth.

NBC won the week with a network average of 12.6 in the A.C. Nielsen Co. ratings. CBS was second with 12.0 and ABC was third with 9.8. The networks say this means that in an average prime-time minute 12.6 percent of the nation's TV homes were tuned to NBC.

An NBC News special on first lady Nancy Reagan placed 21st in the ratings.

CBS kept its lead among the evening news shows, with 11.2, as NBC had a 9.6 mark to take over second place from ABC, which had 9.2.