In this Feb. 11, 2011 file photo, Rep. Robert Andrews (D-N.J.), left, accompanied by Rep. Tim Bishop (D-N.Y.), speaks on Capitol Hill in Washington, D.C. Andrews announced Tuesday that he is resigning from Congress after 23 years. (J. Scott Applewhite/AP)

In his 23 years in Congress, Rep. Robert E. Andrews (D-N.J.) has written 646 different pieces of legislation. That is a vast array of bills, covering a vast number of subjects: children’s pajamas, relations with Taiwan, commemorative coins and trade duties on licorice.

But all of Andrews’s bills had one thing in common.

They didn’t become law.

Only four of Andrews’s hundreds of bills have ever passed the House of Representatives. But none of them passed the Senate, so none made it to the president’s desk.

Even in Congress, where the vast majority of bills fail, that is an unusually awful batting average. By those numbers, Andrews would be America’s least successful lawmaker of the past two decades.

Andrews, 56, said Tuesday he would resign in two weeks, taking a position at the law firm Dilworth Paxson. In an interview Tuesday, he insisted that these statistics don’t capture his true record in Congress.

The reason, he said, is that the classic idea of how lawmaking works — an idea becomes a bill, the bill gets a debate, and the debate ends with a vote — does not mean much on today’s Capitol Hill.

“ ‘I’m Just a Bill on Capitol Hill’ is not the way this works. Freestanding bills almost never happen,” Andrews said, referencing the “Schoolhouse Rock” cartoon about how a bill sings and dances its way through Congress.

Instead, lawmaking is now done with massive pieces of legislation crammed full of ideas that might have little to do with one another. What looks like failure, Andrews said, is actually his success at working the new system.

“You should ask yourself how many of the ideas that were a seed planted in the bill that germinated in a larger bill. That’s the way this really works,” he said. In all, he estimated, about 110 of his ideas have become law after being stuck into somebody else’s bill.

Andrews has spent the past two decades as a semi-liberal backbencher with no real leadership roles in the House. Andrews’s legislative clout was reduced sharply when Republicans took the House in 2011, and also by lingering allegations that he used campaign funds to pay for personal and family trips.

But a look at Andrews’s bills shows that his lawmaking ambitions have been enormous, even when his power was not.

Since Andrews arrived in Congress, no other representative has introduced more bills. In second place is Rep. Carolyn B. Maloney (D-N.Y.), followed by Rep. Don Young (R-Alaska), Rep. Charles B. Rangel (D-N.Y.) and former congressman Ron Paul (R-Tex.).

But all of those other lawmakers have managed to pass something into law sometime in their career. Maloney has had nine bills signed into law. Young has had 76. Rangel has had 38. And even Paul had one, a minor bill to convey a piece of federal property in Galveston, Tex.

Andrews has not. The closest he has come has been to watch a senator introduce a bill similar to one of his and then see that Senate bill become law. That’s happened twice, according to Joshua Tauberer, whose site govtrack.us allows users to track and compare vast amounts of data on Congress.

Although it was the companion bills to Andrews’s that were enacted, Tauberer said, he should get some credit for their success.

“Only one of the two companion bills will actually become law, but the work to get either enacted may have been shared by the two sponsors equally,” Tauberer said. “It’s helpful to keep companion bills in mind when quantifying legislative activity.”

In one case, in 1992, both Andrews and Sen. Frank R. Lautenberg (D-N.J.) introduced bills to name a federal courthouse in Camden, N.J. Lautenberg’s version was the one the president signed.

Also, in 1999, both Andrews and Sen. Jeff Sessions (R-Ala.) introduced bills that changed the rules governing benefit plans run by churches. It was Sessions’s bill that, after significant amendments, became law.

The many other bills submitted by Andrews have, over the years, included 11 related to Taiwan, often seeking to show U.S. support for that country in its disputes with China. He has sponsored five bills to mint a commemorative coin in honor of Korean immigrants. And he has introduced at least 30 bills that would lower duties on chemicals used in manufacturing — everything from licorice extract to methoxycarbonyl-terminated perfluorinated polyoxymethylene-polyoxyethylene.

And he struck out every time.

At least on paper.

“People think . . . well, you introduce a bill, and then you walk around and try to get people to co-sponsor it” and then it passes, Andrews said. “You know, that happens about as often as a black swan.”

Instead, Andrews says, he introduces bills so that he has legislative language ready for an opening. That opening, usually, is what Hill staffers call a “moving vehicle” — a giant piece of legislation that, unlike most of Congress’s inert bills, actually has a chance of passage.

“What happens in 90 percent of the [cases] is that certain bills move because they have to,” Andrews said — often because some important deadline is about to expire. “And those bills carry with them hundreds of ideas, or thousands of ideas that people have worked on over the years.”

Andrews said he has learned how to get his ideas on board by stockpiling legislative language that can be easily picked up and inserted into larger legislation.

As evidence of his success, he cited changes to the military health-care program Tricare and rules about insurance coverage of orthotic devices. Some other ideas have changed government policy without being passed in any form: In 2012, Andrews trumpeted a decision by mortgage firms Fannie Mae and Freddie Mac to require prompt decisions on short sales. Andrews’s actual bill to require that change had died on Capitol Hill.