[ic] SQL sum function in query tag?

Joshua Lavin interchange-users@icdevgroup.org
Tue Jan 28 16:07:00 2003


> To return the sum under the column name 'length' use 'AS', also, sku 
> is a
> string so needs to be quoted:
>
> SELECT time_format(sum(length), '%T') AS length FROM music WHERE sku =
> '[item-code]'

Thanks for all the help. The [sql pos 0] worked (with or without single 
quotes around sku), but not for everything.

Adding track times with MySQL's time_format doesn't work. I tested it at 
the command line, and it would add the seconds, say 242, and take the 
hundreds place (2), and add it to the minutes. If the seconds tens place 
were over 6, like 292, it would return NULL.

"AS length" did indeed change the column name.

So, I guess the only way to make it work would be manually, dividing by 
60, etc.

Thanks again!

Josh