0
我想總結所有支付的總金額,當我這樣做時答案以科學記數法給出,而不是具有特定小數位數的浮點數。我所關注的專欄是total_amount,如果您可以請告訴我這樣做的正確方法,以及關於Case功能的一些背景,那將非常棒。SQL使用案例來轉換數據類型
Select customer.customer_id, customer.email, count(payment.payment_date) as payments_count,
round(sum(Cast(payment.amount as numeric(4,2))), 2) as total_amount
From customer join payment
on customer.customer_id = payment.customer_id
group by customer.customer_id
請標記您的問題。 –
@GordonLinoff看起來像MySQL –
你的輪次和演員應該已經給你2位小數。你真正想要什麼輸出。順便說一下,您正在使用「GROUP BY」選擇非聚合列。 –