+ 2

SQL aggerate

find this difficult Retrieve the average length of a track in seconds for tracks greater than 1 MB. I have: SELECT AVG(Milleseconds*1000) AS AvrgTrack FROM Track WHERE Bytes*8000 > 1000000 the answer is 270.3458 I get 269.92215 I have used Bytes*8 giving me 270.03397

12th Feb 2018, 2:28 AM
Brian Null
Brian Null - avatar
8 Respuestas
+ 1
This one took me a while. here's what worked for me. SELECT AVG (Milliseconds/1000) FROM Track WHERE Bytes > 1024*1024
23rd Feb 2018, 6:13 AM
matthew plett
matthew plett - avatar
0
Could be a little accuracy problem. 1 MB is 1048576 bytes.
12th Feb 2018, 6:47 PM
SQL Guy
0
Yes I have used both Bytes*1024*1024 and Bytes*1048576 Both give me the same answer Bytes*8 gives me 270.03397 I am brining to think its how my query is structured is the problem
12th Feb 2018, 9:36 PM
Brian Null
Brian Null - avatar
0
I believe my query is not aggregating the Milliseconds correctly.
16th Feb 2018, 1:37 PM
Brian Null
Brian Null - avatar
0
Thank you that was the one method I did think about
23rd Feb 2018, 12:40 PM
Brian Null
Brian Null - avatar
0
Retrieve the average length of a track in seconds for tracks greater than 1 MB. Ans; SELECT AVG(Milleseconds/1000) AS AvrgLength FROM Track WHERE Bytes > 1024*1024
11th Mar 2018, 11:50 AM
AMANUEL MOGES
AMANUEL MOGES - avatar
0
SELECT AVG (Milliseconds/1000) FROM Track WHERE Bytes > 1024*1024 How "Milliseconds/1000"??? transfer of milliseconds in seconds in the condition
14th Aug 2018, 11:38 AM
Andrew
0
a in the source table, values in milliseconds
14th Aug 2018, 11:42 AM
Andrew