The global economy is in a massive transition from a fossil-fuel-based energy system to one using sophisticated renewable energy technologies. For tens of thousands of fossil fuel workers, though, the energy industry outlook is not promising. For coal industry workers, the future looks particularly bleak. However, research I conducted with Edward Louie of Oregon State University offers hope for a better future based on retraining workers. Our study (published in the journal Energy Economics) quantified the costs and benefits of retraining coal workers for employment in the rapidly expanding solar photovoltaic industry—and it explores different ways to pay for this retraining.

First, some background on the coal industry: Profitability for U.S. coal-fired power plants has been declining and coal use has dropped radically since 2007—a trend that is expected to continue. This reduced profitably has driven a steep cut in coal plants. The U.S. Energy Information Administration notes that between 2010 and 2012, 14 gigawatts (GW) of coal-fired capacity was retired and that a total of 60 GW will be retired by 2020. What these dry government numbers leave out is the effect on coal workers and their families as coal mines close and one major coal company after another files for bankruptcy. Even the world’s largest private-sector coal company, Peabody Energy, declared bankruptcy this past April. And as coal investors have fled in droves to invest in more profitable companies and industries, coal workers have been left with pink slips and mortgages on houses with few buyers in blighted coal country. It is clear that coal is no longer a competitive form of electrical generation.

The one energy sector that is growing at an incredible rate is the solar industry—and it is hiring.

For decades the solar industry has battled against enormous government subsidies for coal. But because of the tremendous drop in costs for solar technology, solar adoption is now rising rapidly. Bloomberg reports that the American solar industry had a record first quarter in 2016, and for the first time, it drove the majority of new power generation. The U.S. solar industry is creating a lot of jobs, bringing on new workers 12 times faster than the overall economy. As of November 2015, the solar industry employed 208,859 solar workers, which is already larger than the roughly 150,000 jobs remaining in the domestic coal industry. (It is important to note that both of these numbers are severely limited by the data available, but it can be safely assumed there are far more solar workers in the U.S. today than there were last year—and far fewer coal workers than in 2014.)

Our study found that this growth of solar-related employment could benefit coal workers, by easily absorbing the coal-industry layoffs over the next 15 years and offering full-time careers.

Using data from the Bureau of Labor Statistics, we looked at all current coal industry positions (from engineers to mining and power plant operators to administrative workers), the skill sets required for each (for example, specific degrees and amount of work experience), and their respective average salaries. For each type of coal position, we determined the closest equivalent solar position and salary. For example, an operations engineer in the coal industry could retrain to be a manufacturing technician in solar and expect about a 10% salary increase. Similarly, explosive workers, ordinance handlers, and blasters in the coal industry could use their sophisticated safety experience and obtain additional training to become commercial solar technicians and earn about 11% more on average.

Our results show that there is a wide variety of employment opportunities in the solar industry, and that the annual pay is attractive at all levels of education, with even the lowest skilled jobs paying a living wage (e.g., janitors in the coal industry could increase their salaries by 7% by becoming low-skilled mechanical assemblers in the solar industry). In general, we found that after retraining, technical workers would make more in the solar industry than previously in coal. However, managers and particularly executives would make less.

By identifying the requisite skills to be learned and the various educational programs available, we also calculated the time and investment it would take to retrain an employee. Most coal workers could not simply walk into a solar job; they would need some retraining. But certain positions required less training—for example, a structural engineer in the coal industry would not need additional schooling to work as one in the solar industry. And for some coal employees, the retraining would only amount to a short course or on-the-job training.

More advanced positions, however, would require more education. Some solar-related engineering positions call for up to a four-year university degree, which has a large range in costs from $18,000 to over $136,000 depending on the school.

Our paper includes appendices that can help current coal workers match their existing job to the best potential fits in solar, as well as what training they’ll need. It should be noted, however, that the costs and specific schools used as examples were just that.

The results of the study show that a relatively minor investment ($180 million to $1.8 billion, based on best and worst case scenarios) in retraining would allow the vast majority of U.S. coal workers to switch to solar-related positions. Of course, training times depend on type of job and prior experience.

Our paper evaluated four ways this training could be funded. First, coal workers could fund their own retraining. Second, coal companies could fund retraining of their own workers before laying them off. There are several reasons employers may want to consider this—whether it’s because they feel an obligation to take care of their workers, are diversifying their energy portfolios the way some oil companies have done to be more resilient, or want to improve their public perception. It would only take 5% of coal company revenue from a single year to provide “scholarships” to their workers to fully pay for the retraining they would need to move to solar. A third way to fund would be individual states providing “coal to solar” transition programs. And the fourth option is the federal government could fund the retraining.

Workers in any declining industry can learn from the coal industry. They can provide themselves valuable job security insurance by preemptively retraining, and there are numerous opportunities for online training (and even working) in a wide variety of fields. Businesses in tangential industries may also want to consider retraining their own workers—electric utilities, for example, can retrain their coal-fired power plant workers for positions involving utility-scale solar farms.

The writing on the wall for the coal industry is clear. Price pressure from natural gas, wind, and solar has been relentless. Increasingly stringent environmental regulations to curb pollution continue to raise the costs of coal, and public perception of the industry continues to fall. The growing threat of liability due to inherent greenhouse gas emissions that come from coal combustion may climb to the hundreds of trillions of dollars. Young coal workers, in particular, should consider retraining for a job in solar now.