Mysql
 sql >> Database >  >> RDS >> Mysql

Esecuzione di operazioni matematiche su colonne temporanee in SQL

Forse intendevi qualcosa del genere:

SELECT
  t.t_id,
  t.occurrences,
  t.value / tm.occurrences AS newValue
FROM table t
  INNER JOIN (
    SELECT
      tm_id,
      COUNT(*) AS occurrences
    FROM table_map
    GROUP BY tm_id
    HAVING COUNT(*) > 1
  ) tm ON t.t_id = tm.tm_id