Delta Air Lines yesterday reported a profit of $20.8 million in its fiscal year ended June 30 despite rising costs, fare wars and a slumping economy, all of which have hurt many of Delta's competitors.

And profits for UAL Inc., parent of one of those competitors, United Airlines, dropped in the second quarter, it was reported yesterday.

Among other major companies reporting were Consolidated Rail Corp. and Santa Fe Industries, with higher second-quarter earnings; and 3M Co., with lower earnings.

Delta, which reported its first quarterly loss in 25 years three months ago, said it earned a fourth-quarter profit of $23.1 million (58 cents a share) compared with $47.6 million ($1.20) a year ago. Revenue was down slightly to $950.3 million from $954.2 million.

For the fiscal year, Delta's profit was off 86 percent from the year-ago level of $146.5 million. Earnings per share fell to 52 cents from $3.68. Revenue was $3.6 billion, up 2 percent from $3.5 billion in the previous fiscal year.

In reporting the lower earnings at UAL Inc., Chairman Richard J. Ferris said UAL's Westin Hotels earnings declined as a result of a lower occupancy rate caused by the sagging economy.

Net income for the quarter was $5.47 million (18 cents a share) on revenues of $1.365 billion compared with net income a year earlier of $8.53 million (29 cents) on revenues of $1.331 billion.

For the first half, the company lost $123.84 million on revenues of $2.569 billion compared with its $12.67 million loss in the first half of 1981 on revenues of $2.560 billion.

Airline operating earnings improved for the quarter to $22.4 million on a 2 percent rise in revenues to $1.2 billion from operating earnings of $332,000 a year ago.

But the airline recorded a net loss of $4.4 million in the quarter compared with a net loss of $3 million a year earlier.

For the half, the airline had a net loss of $134.1 million compared with a net loss of $30.1 million in the first half of 1981. Operating revenues were unchanged at $2.26 billion.

Consolidated Rail Corp.'s second-quarter net income soared to $56.2 million ($2.21 a share) from $13.8 million (52 cents) a year earlier although revenue slipped to $958.8 million from $1.073 billion.

Conrail also reported its first net income for the first half of any year since it began operations on April 1, 1976. The profits figure for the six months was $30.6 million on revenue of $1.903 billion compared with a $52.1 million loss in the first half of 1981 on revenue of $2.132 billion.

However, under the financial reporting requirements of the Interstate Commerce Commission, Conrail showed a loss of $7.9 million for the second quarter of 1982 and a loss of $25.2 million for the first half of 1982 compared with a second quarter 1981 loss of $12 million and a first half 1981 loss of $69.5 million.

Conrail said its second-quarter 1982 financial results were achieved despite a 14.7 percent decrease in freight traffic compared with the same period of 1981.

L. Stanley Craine, Conrail chairman and chief executive officer, said the net income for the second quarter and the first half of 1982 were achieved in large measure due to Conrail employes holding the line on wage increases, as well as other continuing cost reductions by the railroad.

Led by its railroad operations, Santa Fe Industries posted a record $64.6 million (73 cents a share) in net income for the second quarter, a 10 percent increase over the same period last year.

The company said Wednesday it achieved the higher earnings despite a drop in revenues to $798.8 million from $862.7 million in the same period last year.

Net income for the first half was $98.4 million ($1.07), down from $127.1 million ($1.44) in the same period last year as a result of poor first-quarter earnings.

Santa Fe's rail operations led the increase in earnings, contributing $33.9 million before taxes in the second quarter of 1982 compared with $30.4 million last year.

Pretax earnings from oil operations declined $3.6 million to $34.2 million.

3M Co. reported yesterday that net income was down during the second quarter and first half of the year because of the sluggish U.S. economy and the effects of a stronger dollar on overseas operations, but said that an earnings gain for all of 1982 still is possible.

Second-quarter net income fell 7.9 percent to $158.6 million ($1.35 a share) from $172.2 million ($1.47) in the corresponding quarter last year. Worldwide sales rose 1.4 percent to $1.687 billion from $1.664 billion.

First-half earnings declined 8.8 percent to $311.1 million ($2.65) from $341.2 million ($2.91) as sales increased 3.3 percent to $3.353 billion from $3.246 billion.