Skip to content
Advertisement

get started minutes from 0:00:00 type values

I’m not really used to sql but I have a csv file with a lot of rows and columns so I decided to do the needed work in sql. I have a Table with 3 columns and a few thousand rows.

Column duration is type varchar and includes duration of phoncalls in this format: hours:minuts:seconds.

I need to calculate $ per started minute. Let’s say 100$ per minute. So if duration contains 0:13:25 it has to be 1400$.

my unsuccessful attempt was to add a new row “minutes”, insert the number of started minutes and then go on calculating with it. But to me it doesn’t matter how the solution works.

Since it’s been a few years since I worked with sql I would be glad if someone can come up with a copy-paste solution I can use.

Thanks!

Advertisement

Answer

If your data looks like this then

source     | destination | duration 
4940xxxxxx | 00893xxxxx  | 00:01:07

select ROUND(((minute('00:01:07')*60 + second('00:01:07'))/60)*100, 2) as Extausionate_Bill;

Charging for every started minute

select CEILING(((minute('00:01:07')*60 + second('00:01:07'))/60))*100 as Extausionate_Bill;

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement