Starting my first steps in SQL.

I'm trying to insert the last row of a timestamped table to another table.

I've written this trigger:

```
CREATE TRIGGER update_analysis()
AFTER INSERT ON data
FOR EACH ROW
    EXECUTE PROCEDURE insert_to_analysis();

```

I've defined a function, which I know is wrong, but don't understand how to write it correctly. (the target table has these columns)

```
CREATE FUNCTION UPDATE_ANALYSIS() RETURNS TABLE
AS
$$ BEGIN
INSERT INTO ANALYSIS (TIME, CYCLE_NUMBER,CAT1,CAT2,CAT3)
SELECT (TIME, CYCLENO , I1 , I2 * 2 ,I3*3)
FROM DATA
ORDER BY TIME DESC
LIMIT 1;)

RETURN 
END;

$$ LANGUAGE 'plpgsql';

```

Thanks in advance