clear markdown compare help best fiddles feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3601588 fiddles created (48005 in the last week).

CREATE TABLE tab(ColumnA DECIMAL(10,2), ColumnB DECIMAL(10,2), ColumnC DECIMAL(10,2))
 hidden batch(es)


INSERT INTO tab(ColumnA, ColumnB, ColumnC) VALUES (2, 10, 2),(3, 15, 6),(7, 14, 3)
3 rows affected
 hidden batch(es)


SELECT * FROM tab
ColumnA ColumnB ColumnC
2.00 10.00 2.00
3.00 15.00 6.00
7.00 14.00 3.00
 hidden batch(es)


SELECT ColumnA, ColumnB, sub.calccolumn1, sub.calccolumn1 / ColumnC AS calccolumn2 FROM tab t CROSS APPLY (VALUES (t.ColumnA + t.ColumnB)) AS sub(calccolumn1);
ColumnA ColumnB calccolumn1 calccolumn2
2.00 10.00 12.00 6.0000000000000
3.00 15.00 18.00 3.0000000000000
7.00 14.00 21.00 7.0000000000000
 hidden batch(es)


SELECT ColumnA, ColumnB, sub.calccolumn1, sub.calccolumn1 / ColumnC AS calccolumn2 FROM tab t CROSS APPLY (VALUES (t.ColumnA + t.ColumnB)) AS sub(calccolumn1) WHERE sub.calccolumn1 = 12;
ColumnA ColumnB calccolumn1 calccolumn2
2.00 10.00 12.00 6.0000000000000
 hidden batch(es)