-2

I need your expertise on my problem

SELECT 
(begBal) AS 'Beg. Balance',
(deposit) AS 'Deposit',
(withdrawal) AS 'Withdrawn',
(begBal+deposit-withdrawal) AS Balance
FROM savingsTable;

result:

| Beg. Balance | Deposit | Withdrawal | Balance | 
|         2000 |    1500 |       1100 |    2400 |

our teacher wants the result like this :

| Beg. Balance |  Deposit | Withdrawal |  Balance |
|     2,000.00 | 1,500.00 |   1,100.00 | 2,400.00 |

please include a little explanation on your answer. thank you very much in advance.

4

3 回答 3

1

You can use FORMAT()

SELECT FORMAT(columnName, 2)

SOURCE:

于 2013-03-27T16:03:20.697 回答
0

You can use the FORMAT() function to do this.

于 2013-03-27T16:03:37.463 回答
0

I assume that these are decimal fields. If not, it doesn't really make sense to have the .00 since it can't be stored. Either way, just add FORMAT(field, 2), e.g.

SELECT FORMAT(begBal, 2) AS 'Beg. Balance',
于 2013-03-27T16:04:13.927 回答