* Trading quiet as investors await clarity on Greek debt
* Energy rises alongside oil prices; AT&T rallies on upgrades
* Facebook ends at record, its market cap surpasses Wal-Mart's
* Dow, S&P 500 and Nasdaq all rise 0.1 pct (Updates to close)
By Ryan Vlastelica
NEW YORK, June 23 (Reuters) - U.S. stocks ended with slight gains on Tuesday, with the Nasdaq eking out another record close while investors continued to await clarity on whether Greece could reach a deal to prevent defaulting on its loans.
The day's action was quiet, with trading volume below average. While energy shares rose alongside a jump in the price of crude oil, a sharp rise in the U.S. dollar capped broader gains.
While there were no major developments involving Greece, investors continued to hope that the country's newest budget proposals - introduced on Monday - would avert a looming default.
Greece needs fresh funds to avoid defaulting on a $1.8 billion debt repayment to the International Monetary Fund on June 30. Equities have been largely driven by Greece lately, with investors concerned that if the country defaults, it may have to leave the euro or the European Union, potentially shaking the region's economic foundations.
"The market seems to expect that this will end favorably, or at least benignly, but I think people need to be nimble right now as circumstances could change at any time," said Steve Sosnick, equity-risk manager at Timber Hill/Interactive Brokers Group in Greenwich, Connecticut.
"Greece may not be all that meaningful to the U.S. market, but it could have a big impact on the euro and the dollar, and it is unclear how big of an impact that will have on stocks."
The U.S. dollar index, which measures the greenback against a basket of currencies, rose 1.1 percent. A strong dollar is considered a headwind for equity prices as it weighs on the profits of multinational corporations.
U.S. crude futures settled up 1 percent at $61.01 per barrel, lifted ahead of U.S. inventory data expected to show strong demand for gasoline. The S&P energy index rose 0.3 percent and was one of the day's top-performing sectors. Halliburton Co rose 0.9 percent to $44.49.
AT&T Inc rose 2.5 percent to $35.91 and was one of the biggest percentage gainers on the S&P 500 after at least two brokerages upgraded the stock.
Facebook Inc shares rose 3.7 percent to $87.88, a record close. With the day's gains, the social network's market value is now bigger than that of Dow component Wal-Mart Stores Inc.
The Dow Jones industrial average rose 24.29 points, or 0.13 percent, to 18,144.07, the S&P 500 gained 1.35 points, or 0.06 percent, to 2,124.2 and the Nasdaq Composite added 6.12 points, or 0.12 percent, to 5,160.10. The Nasdaq ended at a record while the S&P 500 closed 0.3 percent below its own record.
Advancing issues outnumbered declining ones on the NYSE by 1,772 to 1,276, for a 1.39-to-1 ratio on the upside; on the Nasdaq, 1,567 issues rose and 1,203 fell for a 1.30-to-1 ratio favoring advancers.
The S&P 500 posted 43 new 52-week highs and 2 new lows; the Nasdaq Composite recorded 180 new highs and 23 new lows.
About 5.4 billion shares traded on all U.S. platforms, according to BATS exchange data, below the month-to-date average of 6.15 billion. (Editing by Nick Zieminski)