My servers DB is using MySQL ver4.1.10.
I need to use a query in the type CREATE VIEW
CREATE VIEW currentCostOfStock AS
SELECT P.partName, P.partNo, P.manufacturer, S.vehicleType, S.years, S.price, S.stockLevel, S.price * S.stockLevel AS productCost, SUM productCost AS stockCost
FROM Parts...
I have come stuck with averaging a column with type of Time.
I know there is a function AVG() that I can use to filter the average of a column, however, this brings back an integer.
Is there any way to return the average in time format (IE 00:00:00)?
BACKGROUND INFO:
SELECT `estimatedTime`...
The data type is time, and the default is 00:00:00.
Thinking about it, the best default will peobably be 00:00. However, for the sake of getting this problem sorted I will leave it at 00:00:00.
Cool,
SELECT `estimatedTime`
FROM job_sheet;
Returns,
01:00:00
21:30:00
01:00:00
If the data in the table were all 01:00:00 the AVG query returns 10000. I threw in the 21:30:00 to test.
Ok, for example:
SELECT AVG( `estimatedTime` )
FROM job_sheet;
Returns:
77666.666666667
Which should be something like 07:76:66 (ignoring the everything after the decimal). Which obviously should be 08:17:06... I think... you get what I mean LOL. It should be this because it is the answer...
I have come stuck with averaging a column with type of Time.
I know there is a function AVG() that I can use to filter the average of a column, however, this brings back an integer.
Is there any way to return the average in time format (IE 00:00:00)?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.