how to optimize this query for my school project : its my assignment kindly help me to optimzed below two quries

Optimize Assignment 1:

    SELECT n.node_id,
    MIN(LEAST(n.date,ec.date)) date
    FROM n,
    ec
    WHERE (n.node_id = ec.node_id_from OR n.node_id = ec.node_id_to)
    AND n.date - ec.date > 0
    GROUP BY n.node_id;

Optimize Assignment 2:

  

    SELECT TO_CHAR(CONVERT_TIMEZONE ('UTC','America/Los_Angeles',tableA."date"),
          'YYYY-MM') AS "date_month",
    COUNT(DISTINCT CASE WHEN (tableB."date" IS NOT NULL) THEN tableB._id ELSE NULL
          END) AS "tableB.countB",
    COUNT(DISTINCT CASE WHEN (tableC."date" IS NOT NULL) THEN tableC._id ELSE NULL
          END) AS "tableC.countC"
    FROM tableA AS tableA
    LEFT JOIN tableB AS tableB ON (DATE (CONVERT_TIMEZONE ('UTC',
          'America/Los_Angeles',tableB."date"))) = (DATE (CONVERT_TIMEZONE ('UTC',
          'America/Los_Angeles',tableA."date")))
    LEFT JOIN tableC AS tableC ON (DATE (CONVERT_TIMEZONE ('UTC',
          'America/Los_Angeles',tableC."date"))) = (DATE (CONVERT_TIMEZONE ('UTC',
          'America/Los_Angeles',tableA."date")))
    WHERE tableA."date" >= CONVERT_TIMEZONE ('America/Los_Angeles','UTC',DATEADD (
          month,-17,DATE_TRUNC('month',DATE_TRUNC('day',CONVERT_TIMEZONE ('UTC',
          'America/Los_Angeles',GETDATE ()))))
    GROUP BY 1
    ORDER BY 1 DESC LIMIT 500;