Domanda

I have an assignment to make a SELECT STATEMENT using no FROM clause. I'm trying to multiply the Price and TaxRate to make a TaxAmount column but I'm getting an error saying invalid column name for Price and TaxRate.

SELECT '100 (dollars)' AS Price, '.07 (7 percent)' AS TaxRate,
Price * TaxRate AS TaxAmount, TaxAmount + Price AS Total
È stato utile?

Soluzione

SELECT 100 AS Price, .07 AS TaxRate, (100 * .07) AS TaxAmount, ((100 * .07) + 100) AS Total

You don't need to make it look like 100 (dollars) I don't think, that wouldn't make sense. If you actually do, you could use

SELECT '100 (dollars)' AS Price, '.07 (7 percent)' AS TaxRate, (100 * .07) AS TaxAmount, ((100 * .07) + 100) AS Total

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top