Trim a decimal to 2 places Bigquery -
i running query runs sum function , divides number. values 0.0904246741698848, , 1.6419814808335567. want these decimals trimmed 2 spaces past decimal point. schema float. here code. help.
#standardsql select serial, max(createdat) latest_use, sum(connectiontime/3600) total_hours, count(distinct deviceid) devices_connected `dataworks-356fa.firebasearchive.firebase_connectioninfo` peripheraltype = 1 or peripheraltype = 2 or peripheraltype = 12 group serial order latest_use desc
#standardsql `data` ( select 0.0904246741698848 val union select 1.6419814808335567 ) select val, round(val, 2) rounded_val `data`
for example, assuming want apply total_hours column :
#standardsql select serial, max(createdat) latest_use, round(sum(connectiontime/3600),2) total_hours, count(distinct deviceid) devices_connected `dataworks-356fa.firebasearchive.firebase_connectioninfo` peripheraltype = 1 or peripheraltype = 2 or peripheraltype = 12 group serial order latest_use desc
Comments
Post a Comment