And the amount of energy produced is in the same ballpark too?
We're talking cost per kWhr, so yes, per kWhr.
The issue is that coal is quoted at 10c/kWhr, solar at a higher rate, but that neglects subsidies and negative externalities like climate change. Once you balance the subsidies and introduce a carbon price, coal starts to look a lot worse.
And there's no moral problem. To paraphrase Winston Churchill - you're just haggling over the price.