Вопрос

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
Это было полезно?

Решение

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top