Creating a view with a Decimal column
Posted on 2004-04-30
I'm working with a database that logs user activity. The database was created by the application that does the logging. One of the fields is a VARCHAR field that contains only numeric data. It represents the number of secends a user was logged on dring a session.
I'm trying to create a view that I'll report against. In this view, I'm including the user name, the time the event was logged, the original elapsed time (in seconds) and a field calculated from elapsed time to give me the elapsed time in minutes (elapsed_time/60). The problem I have is that the calculated field is created as an integer, and therefore the result is rounded. I expect that I'll be using the data to provide a roll-up summary, so the rounding errors can become significant over time. I'd like to know how I might make this calculated field a decimal field. Am I approaching this correctly?
Below is the SQL code that I used to creat the view as it is now. Any help would be appreciated.
DROP VIEW time_detail
CREATE VIEW time_detail
SELECT LoggedAt,User_Name,elapsed_time,(elapsed_time/60) AS elapsed_minutes
WHERE (elapsed_time is NOT NULL)