Home > other >  MariaDB SELECT arithmetic operation based on type
MariaDB SELECT arithmetic operation based on type

Time:01-08

I have following query in MariaDB

MariaDB [nova]> SELECT hostname, instances.created_at, 
  SUM(TIMESTAMPDIFF(hour,instances.created_at, NOW())) AS 'Total Hours',  
  JSON_EXTRACT(flavor, '$.cur."nova_object.data".name') AS FLAVOR  
 FROM instances  
 JOIN instance_extra ON instances.uuid = instance_extra.instance_uuid  
 WHERE (vm_state='active' OR vm_state='stopped') 
  AND hostname LIKE '           
  • Related