SELECT
*
FROM (SELECT
TYPE, MAX(DATE) AS DATE
FROM TABLE
INNER JOIN USERS ON USERS.ID = TABLE.ID
WHERE
USERS.NAME = 'Test'
GROUP BY
TYPE)
ORDER BY DATE DESC
SELECT
TYPE,
MAX(DATE) AS DT
FROM TABLE
INNER JOIN USERS ON USERS.ID = TABLE.ID
WHERE
USERS.NAME = 'Test'
GROUP BY
TYPE
ORDER BY DT DESC
SELECT
LOGIN,
SUM(IF(TYPE=0, SUM, 0)) OUT_COME,
SUM(IF(TYPE=1, SUM, 0)) IN_COME,
FROM
INFO_USER
GROUP BY
LOGIN
NEW.FIELD_NAME = SUBSTRING(NEW.FIELD_NAME FROM 1 FOR 70),