
437 N.W.2d 416 (1989)
NATIONAL CAN CORPORATION, Relator,
v.
COMMISSIONER OF REVENUE, Respondent.
No. C6-88-2062.
Supreme Court of Minnesota.
March 24, 1989.
*417 John T. Johanneson, Philip T. Colton, St. Paul, for relator.
Thomas K. Overton, Sp. Asst. Atty. Gen., Tax Litigation Div., St. Paul, for respondent.
Heard, considered and decided by the court en banc.
POPOVICH, Chief Justice.
This matter is before us on a writ of certiorari after the Minnesota Tax Court affirmed an order of the Commissioner of Revenue ("Commissioner") assessing additional taxes on National Can Corporation ("National Can") totaling $310,831.16 for the years ending December 31, 1981 and 1982. National Can challenged the propriety of the Commissioner's application of Minn.Stat. § 290.095, subd. 3(c). National Can also argued that the Commissioner's application of the statute violated the equal *418 protection and commerce clauses of the United States and Minnesota Constitutions. We disagree.

I.
National Can is a Delaware corporation having its principal place of business in Chicago, Illinois. It manufactures and sells beer and beverage containers and operates in numerous states and foreign countries. During the years in question National Can was required to pay corporate income tax in Minnesota based on the three-factor apportionment formula in Minn.Stat. § 290.19 (1980) (repealed and recodified at Minn.Stat. § 290.191 (1987)). Based on the apportionment formula, the percentage of National Can's total business attributable to Minnesota was 3.5451% in 1981 and 4.0860% in 1982.
Apache Container Corporation ("Apache"), a Delaware corporation with its principal place of business in Minnesota, was a wholly-owned subsidiary of National Can and operated a container manufacturing business solely in Minnesota. Apache did not apportion its income under Minn. Stat. § 290.19 and its income was fully taxable in Minnesota. During the years 1974 through 1981, Apache incurred net operating losses totaling $10,919,901, after which Apache was liquidated into National Can. Pursuant to provisions in the Internal Revenue Code and Minn.Stat. § 290.138 (1980) (repealed 1988), National Can succeeded to the net operating losses of Apache.
To determine its Minnesota income tax in 1981, National Can first subtracted expenses and deductions from gross income to determine the total amount of taxable income for the year. Because it did only 3.5% of its business in Minnesota, only that percentage of its total taxable income was apportioned to Minnesota. National Can then deducted from the Minnesota-apportioned income the entire amount of the net operating loss carryovers which it received after the merger with Apache. The Commissioner disallowed Apache's net operating loss carryforward deduction and recalculated National Can's tax by applying the same apportionment factor to the carried over net operating loss deduction as had been used to calculate National Can's 1981 Minnesota income. The recalculation resulted in a reduction of the net operating loss deduction from $5,725,685 to an apportioned net operating loss deduction of $162,757 for 1981 and $6,606 for 1982.

II.
Our review of a case on a writ of certiorari requires that we need only determine whether there is substantial evidence to support the lower court's decision and conclusions of law. Moberg v. Independent School District # 281, 336 N.W.2d 510, 519 (Minn.1983). Here, because the parties stipulated to all of the relevant facts, we need only determine whether the facts amply support the tax court's conclusions of law.
The rules of statutory construction require that "[w]hen the words of a law * * * are clear and free from all ambiguity, the letter of the law shall not be disregarded under the pretext of pursuing the spirit" and that whenever possible all of the provisions in a statute be given effect. Minn.Stat. § 645.16 (1988). Because tax deductions are a matter of "legislative grace," statutes which provide for deductions are to be construed strictly. Northern Natural Gas Co. v. Commissioner of Revenue, 312 Minn. 177, 182, 251 N.W.2d 125, 128 (1977). Taxation is presumed and the burden is on the taxpayer to show it is entitled to a deduction. Any ambiguity as to the availability of the deduction is resolved against the taxpayer. Minneapolis Star & Tribune v. Commissioner of Taxation, 287 Minn. 117, 126, 177 N.W.2d 33, 39 (1970). These are the principles we must apply to interpret the statutes at issue here.
There is no question that pursuant to Minn.Stat. § 290.138, National Can succeeded to the rights, privileges and immunities of Apache. The dispute involves only the interpretation and application of Minn. Stat. § 290.095, which allows the deduction of net operating losses in years other than when the loss occurs. Subdivisions 1 and 2 *419 of the statute, respectively, authorize the deduction and define the terms used in the statute. The definition of net operating loss is the excess of deductions over income. The definition of "net operating loss deduction" is "the aggregate of the net operating loss carrybacks and carryovers to the taxable year, computed in accordance with subdivision 3." Minn.Stat. § 290.095, subd. 2 (1980).
Subdivision 3 explains the timing and method for calculating the deduction. Paragraph (a) states the specific years to which net operating losses may be carried. Depending upon when the loss occurred, it can be carried back and forward to other years. In 1980, the statute provided that losses could be carried forward to each of the five taxable years after the loss and back to each of the three taxable years preceding the loss. Minn.Stat. § 290.095, subd. 3(a) (1980). The 1987 amendments to the statute provided that losses incurred in a taxable year beginning after December 31, 1986, could be carried over to each of the 15 taxable years following the loss.
Subd. 3(b) instructs corporate taxpayers how the net operating losses may be carried to other years. First, the entire amount of the loss must be carried to the earliest year to which it may be carried. Any amount of loss remaining after deducting from the earliest year may then be carried to other years. Thus, if a corporation had income in 1978, 1979 and 1980, incurred a significant loss in 1981, and wanted to carry over the loss to other taxable years, it would first have to deduct the loss from its 1978 income. Any remaining loss could then be carried to 1979 and 1980 in that order. If the entire amount of the loss had not been used up by carrying it back, the remaining loss could be carried forward to the first five post-loss years.
Minn.Stat. § 290.095, subd. 3(c), provided:
Where a corporation does business both within and without Minnesota, and apportions its income under the provisions of section 290.19, the net operating loss deduction shall be allowed to the extent of the apportionment ratio of the loss year, or the year to which the loss is carried, whichever is smaller.
The remaining paragraphs of subd. 3 are not at issue here. The only other relevant provision of the statute is subdivision 4(a) which prohibits corporations from deducting losses incurred from income-producing activities which are not subject to tax in Minnesota.
National Can argued it should be allowed to deduct the full amount of Apache's net operating losses from its Minnesota income. In support of its argument, National Can suggested (1) because subdivision 3(b) of the statute uses the word "entire," it should be construed to mean the entire amount of net operating loss is deductible; (2) Minn.Stat. § 290.095, subd. 3(c), should not be applied to consolidation/merger situations; and (3) subdivision 4(a) by prohibiting corporations from deducting losses from out-of-state operations implies that losses from in-state operations are fully deductible. To accept any of National Can's arguments requires that fundamental principles of statutory construction be ignored.
First, National Can's focus on the word "entire" in subd. 3(b) overlooks the obvious intent of the provision. When read in its entirety, it is clear the legislature intended to establish a uniform method for determining the year to which net operating losses are carried. Under subd. 3(b), corporations must apply the losses to the earliest possible year and every year thereafter until the loss is completely used up. Because the court must give effect to the intent of the legislature and the legislature obviously did not intend subd. 3(b) to be determinative of the amount of the net operating loss deduction, this part of National Can's argument fails.
The second reason National Can proposes for allowing the deduction is that subd. 3(c) does not apply in merger/consolidation situations. Nowhere in the statute is there an exception for corporations which have succeeded to the net operating losses of another company. To read such an exception into the statutory language would require the court to ignore the explicit *420 language of the statute. Moreover, in Minneapolis Star and Tribune v. Commissioner of Taxation, we applied the same statute to a corporate merger/consolidation situation. While National Can's argument, that the losses should be fully deductible because they were incurred by a corporation which did business only in Minnesota and did not apportion its income, may be plausible, subd. 3(c) specifically limits the amount of the net operating loss carryover deduction available to corporations which do business both in and out of Minnesota. It is undisputed that National Can is such a corporation and, there being no express exception, the plain language of the statute requires that the deduction be apportioned.
National Can's argument that subd. 3(c) need not be applied because the application of subd. 4(a) sufficiently limits the amount of the deduction is similarly unfounded and violates the basic rule of construction which requires every law to be construed to give effect to all of its provisions. National Can would have the court completely ignore subd. 3(c) and only apply the limitation stated in subd. 4(a).
National Can also contends because subd. 3(c) refers to the apportionment ratio of the loss year, it can only be applied where the corporation apportioned its income in both the loss year and the year to which the loss is carried. Because Apache did not apportion its income in the loss year, National Can asserts subd. 3(c) cannot be applied. This argument overlooks the fact that National Can is the corporation claiming the deduction, not Apache. National Can did apportion its income in both the loss year and the year to which the loss was carried; therefore, subd. 3(c) can be given effect using National Can's apportionment ratio for the loss year as the Commissioner did.
National Can relied upon two cases; however, neither case provides a basis for its argument. In Minneapolis Star and Tribune v. Commissioner of Taxation the Star and Tribune sought to deduct net operating loss carryovers of a foreign subsidiary to which it had succeeded after consolidation. There we held that the parent corporation could not deduct the net operating loss carryovers of the subsidiary where the subsidiary's income was not assignable to Minnesota. National Can argues because the predecessor subsidiary whose losses it wishes to deduct was subject to Minnesota tax, the losses should be deductible in full. This reasoning, however, ignores the fact the status of the taxpayers in the two cases is also different. The Star and Tribune was a resident taxpayer which did not apportion its income; conversely, National Can does only a small portion of its business in Minnesota and does apportion its income. In addition to the differences between the taxpayers and predecessor corporations in the two cases, Minneapolis Star and Tribune involved the interpretation of only one portion of the statute  subd. 4(a). Because the Star and Tribune did business only in Minnesota and did not apportion its income, only subd. 4(a) applied. Hence, the result in Minneapolis Star and Tribune is not controlling in this case where the issue is whether subd. 3(c) applies.
The other case cited by National Can in support of its argument is Gulf Oil Corp. v. Lindley, 61 Ohio St.2d 23, 398 N.E.2d 790 (1980). There the taxpayer was a corporation doing business in Ohio which merged with two foreign subsidiaries and sought to deduct the net operating loss carryovers to which it succeeded. The Ohio court concluded, as did this court in Minneapolis Star and Tribune, that although Gulf succeeded to the losses of the subsidiaries, they were not deductible because the income-producing activities of the subsidiaries were not taxable in Ohio. Id. at 31, 398 N.E.2d at 795. The obvious difference between Lindley and this matter is the Ohio statute which the Lindley court was interpreting had no provision similar to subdivision 3(c); therefore, the court had to determine a way to handle such situations. That is not the case here. Minnesota has a statute which explicitly provides that net operating loss carryovers are deductible only to the extent of the apportionment ratio of the loss year or the *421 year to which the loss is carried, whichever is smaller. Subd. 3(c) cannot be avoided and must be given effect.

III.
National Can also claims the Commissioner's interpretation and application of Minn.Stat. § 290.095 violates the equal protection and commerce clauses. We find both claims to be without merit.
When reviewing such a claim, there is a presumption that the statute is constitutionally valid. Nebbia v. People of State of New York, 291 U.S. 502, 537-538, 54 S.Ct. 505, 516, 78 L.Ed. 940 (1934); Reed v. Bjornson, 191 Minn. 254, 257, 253 N.W. 102, 104 (1934). Courts must exercise their power to find a law unconstitutional only when it is absolutely necessary and when the law is unconstitutional beyond a reasonable doubt, not merely because the court deems it to be bad policy or bad economics. Schwartz v. Talmo, 295 Minn. 356, 363, 205 N.W.2d 318, 323 (1973).
To successfully withstand an equal protection challenge, the statute must have a legitimate purpose and the burden imposed must be rationally related to that purpose. Metropolitan Life Ins. Co. v. Ward, 470 U.S. 869, 881, 105 S.Ct. 1676, 1683, 84 L.Ed.2d 751 (1985). The test used previously by this court to determine whether tax statutes violate the equal protection clause includes three elements: (1) the distinctions between the classes must be "genuine and substantial" and provide a "reasonable basis" to justify the legislation; (2) the classification must be relevant to the purpose of the law; and (3) the purpose of the law must be one the state can legitimately attempt to achieve. Miller Brewing Co. v. State, 284 N.W.2d 353, 356 (Minn.1979). It is obvious there are sufficient differences between in-state and non-resident corporations to provide a reasonable basis for the classification. In-state corporations contribute substantially more to Minnesota's economy by providing more employment opportunities in Minnesota, purchasing more Minnesota industrial and agricultural products and paying more taxes in Minnesota. This court has found the economic and tax differences to be a sufficient basis for classification. Id. at 357.
The obvious purpose of subd. 3(c) is to ensure corporations which apportion their income are allowed to deduct only a proportionate share of the expense of producing that income and the classification is reasonably related to that purpose. Moreover, apportionment formulas used to compute the amount of income and deductions attributable to a given jurisdiction have long been recognized as valid. Butler Brothers v. McColgan, 315 U.S. 501, 509, 62 S.Ct. 701, 705, 86 L.Ed. 991 (1942); Westinghouse Electric Corp. v. Tully, 466 U.S. 388, 398, 104 S.Ct. 1856, 1862, 80 L.Ed.2d 388 (1984); Westinghouse Electric Corporation v. Commissioner of Revenue, 398 N.W.2d 530 (Minn.1986).
By requiring corporations to apportion their net operating loss carryovers, the state can achieve its purpose of fairly allocating tax burdens and allowing deductions on a proportionate basis to income. The Minnesota statute applies equally to all companies which do business within and without Minnesota and apportion their income, and thus does not violate the protections of the equal protection clause.
Under the commerce clause, states must refrain from discrimination against interstate commerce because competition among the states is a central element of free-trade policy. Bacchus Imports, Ltd. v. Dias, 468 U.S. 263, 272, 104 S.Ct. 3049, 3055, 82 L.Ed.2d 200 (1984). If a state has a legitimate interest, that interest must be weighed against the burden it would impose upon interstate commerce. Metropolitan Life Insurance Co. v. Ward, 470 U.S. at 881, 105 S.Ct. at 1683. No state may impose a tax which discriminates against commerce by giving a commercial advantage to local business. Bacchus Imports, 468 U.S. at 268, 104 S.Ct. at 3053.
The interest of states in receiving their fair share of corporate income tax is clearly a legitimate interest and the use of apportionment formulas for determining the amount of corporate income tax a foreign corporation must pay has been consistently *422 upheld by the United States Supreme Court as long as the formula is fair and nondiscriminatory. Container Corp. v. Franchise Tax Board, 463 U.S. 159, 170, 103 S.Ct. 2933, 2943, 77 L.Ed.2d 545 (1983). Although the United States Supreme Court has not had occasion to rule on the application of apportionment formulas to net operating loss deductions, in Westinghouse Electric Corp. v. Tully, 466 U.S. 388, 104 S.Ct. 1856, when considering a commerce clause challenge involving a New York tax credit the court suggested that had the tax credit been determined based on the business allocation percentage rather than the export ratio, it would have been fairly apportioned. Id. at 399, 104 S.Ct. at 1863. We find that the determination of the amount of net operating loss carryover deductions based on the apportionment formula does not violate the commerce clause.
The Commissioner properly interpreted and applied Minn.Stat. § 290.095, subd. 3(c), and we find no constitutional violation in that application. Accordingly, we affirm the decision of the tax court.
AFFIRMED.
