1.Find out the SQL ID and Number of SQL Plan exist in AWR History.

define SQL_ID='5cs5a166wqdq8'

SELECT SQL_ID, COUNT (*)
    FROM (SELECT DISTINCT SQL_ID, PLAN_HASH_VALUE FROM DBA_HIST_SQL_PLAN
    WHERE SQL_ID='&SQL_ID')
GROUP BY SQL_ID
ORDER BY 2 DESC;
SQL_ID          COUNT(*)
------------- ----------
5cs5a166wqdq8          2

2.Find out the SQL Plan Hash Value using SQL ID.

SELECT DISTINCT PLAN_HASH_VALUE,SQL_ID  FROM DBA_HIST_SQLSTAT
WHERE SQL_ID='&SQL_ID';
PLAN_HASH_VALUE SQL_ID
--------------- -------------
     1648991925 5cs5a166wqdq8
     1394742193 5cs5a166wqdq8

3.Check the SQL Execution Plan Cost and choose the best one.

Note that you have to select Hash Vale and SNAP_ID for which you want to load into your Plan Baseline.

COL BEGIN_INTERVAL_TIME   FOR A25
COL INSTANCE_NUMBER       FOR 99999999    HEADING INSTANCE|_NUMBER
COL OPTIMIZER_COST        FOR 9999999     HEADING OPTIMIZ|ER_COST
COL DISK_READS_TOTAL      FOR 9999999     HEADING DISK_RE|ADS_TOTAL
COL BUFFER_GETS_TOTAL     FOR 99999999999 HEADING BUFFER_G|ETS_TOTAL
COL ROWS_PROCESSED_TOTAL  FOR 99999999    HEADING ROWS_PROC|ESSED_TOTAL
SELECT SS.SNAP_ID,
    SS.INSTANCE_NUMBER,
    BEGIN_INTERVAL_TIME,
    SQL_ID,
    PLAN_HASH_VALUE,OPTIMIZER_COST,
    DISK_READS_TOTAL,
    BUFFER_GETS_TOTAL,
    ROWS_PROCESSED_TOTAL,
    CPU_TIME_TOTAL,
    ELAPSED_TIME_TOTAL,
    IOWAIT_TOTAL,
    NVL (EXECUTIONS_DELTA, 0) EXECS,
    (  ELAPSED_TIME_DELTA / DECODE (NVL (EXECUTIONS_DELTA, 0), 0, 1, EXECUTIONS_DELTA)) / 1000000 AVG_ETIME,
    (  BUFFER_GETS_DELTA / DECODE (NVL (BUFFER_GETS_DELTA, 0), 0, 1, EXECUTIONS_DELTA)) AVG_LIO
FROM DBA_HIST_SQLSTAT S, DBA_HIST_SNAPSHOT SS
WHERE     SQL_ID = '&SQL_ID'
    AND SS.SNAP_ID = S.SNAP_ID
    AND SS.INSTANCE_NUMBER = S.INSTANCE_NUMBER
    AND EXECUTIONS_DELTA > 0
ORDER BY 1, 2, 3;

                                                                      OPTIMIZ DISK_REA    BUFFER_ ROWS_PROCE                   ELAPSED_
   SNAP_ID BEGIN_INTERVAL_TIME         SQL_ID        PLAN_HASH_VALUE  ER_COST DS_TOTAL GETS_TOTAL SSED_TOTAL CPU_TIME_TOTAL  TIME_TOTAL IOWAIT_TOTAL      EXECS  AVG_ETIME    AVG_LIO
---------- --------------------------- ------------- --------------- -------- -------- ---------- ---------- -------------- ----------- ------------ ---------- ---------- ----------
     37945 09-JUN-19 02.00.08.063 PM   5cs5a166wqdq8      1394742193     1238   369819  358679164   28611683     1.2231E+10  1.5717E+10    424811868      38401  .00314077 987.239942
     37946 09-JUN-19 03.00.11.158 PM   5cs5a166wqdq8      1394742193     1238   372122  395189955   28834621     1.2323E+10  1.5833E+10    426811039      37304 .003102651 978.736623
     37947 09-JUN-19 04.00.14.279 PM   5cs5a166wqdq8      1394742193     1238   374748  445194602   29126020     1.2450E+10  1.6000E+10    430913531      53885 .003091415 927.973035
     37948 09-JUN-19 05.00.17.786 PM   5cs5a166wqdq8      1394742193     1238   377067  496456637   29423432     1.2581E+10  1.6168E+10    433959936      54392 .003099802 942.455416
     37949 09-JUN-19 06.00.21.051 PM   5cs5a166wqdq8      1394742193     1238   377406  503956716   29465958     1.2601E+10  1.6194E+10    434209947       7876 .003243199 952.157694
     37949 09-JUN-19 06.00.21.051 PM   5cs5a166wqdq8      1648991925      192     1260  444058271     230813     2202072159  2381049885       883047      30048 .079241543 14778.2971
     37950 09-JUN-19 07.00.24.294 PM   5cs5a166wqdq8      1648991925      192     3239 1261413110     474903     6568378383  7101254166      2845916      54153 .087162922 15093.1886
     37951 09-JUN-19 08.00.27.520 PM   5cs5a166wqdq8      1648991925      192     5195 1919163388     805917     9903024595  1.0945E+10      5826446      56680 .082039747 14224.8592
     
COL AVG_CPU FOR 99,999,999,999
SELECT SQL_ID,PLAN_HASH_VALUE,AVG(CPU_TIME_TOTAL) AVG_CPU
FROM DBA_HIST_SQLSTAT S, DBA_HIST_SNAPSHOT SS
WHERE     SQL_ID = '&SQL_ID'
    AND SS.SNAP_ID = S.SNAP_ID
    AND SS.INSTANCE_NUMBER = S.INSTANCE_NUMBER
    AND EXECUTIONS_DELTA > 0
GROUP BY SQL_ID,PLAN_HASH_VALUE;

SQL_ID        PLAN_HASH_VALUE         AVG_CPU
------------- --------------- ---------------
5cs5a166wqdq8      1648991925  93,751,956,082
5cs5a166wqdq8      1394742193   9,186,308,758

4.Check that STS has already existed or not in history

if it is exist chose a different name of drop the existing one.

SELECT SQL_ID,PLAN_HASH_VALUE,SQL_TEXT 
FROM TABLE(DBMS_SQLTUNE.SELECT_SQLSET(sqlset_name => 'STS_&SQL_ID'));

BEGIN
  DBMS_SQLTUNE.DROP_SQLSET (sqlset_name => 'STS_&SQL_ID');
END;
/

5.Create a STS(SQL Tuning Set)

BEGIN
  DBMS_SQLTUNE.CREATE_SQLSET(
    sqlset_name => 'STS_&SQL_ID',
    description => 'SQL Tuning Set for loading plan into SQL Plan Baseline');
END;
/

6.Load STS with the lower cost snapshot

-- use BEGIN_SNAP/END_SNAP pair which has less cost for your concerned resource.
DECLARE
  cur sys_refcursor;
BEGIN
  OPEN cur FOR
    SELECT VALUE(P) FROM TABLE(
      DBMS_SQLTUNE.SELECT_WORKLOAD_REPOSITORY(
        BEGIN_SNAP=>&p_begin_snap, END_SNAP=>&p_end_snap,
        BASIC_FILTER=>'SQL_ID = ''&SQL_ID''', ATTRIBUTE_LIST=>'ALL')) p;
  DBMS_SQLTUNE.LOAD_SQLSET( sqlset_name=> '&SQL_ID', populate_cursor=>cur);
  CLOSE cur;
END;
/

7.Check the loaded Plan details.

SELECT SQL_ID,PLAN_HASH_VALUE,SQL_TEXT 
FROM TABLE(DBMS_SQLTUNE.SELECT_SQLSET(sqlset_name => 'STS_&SQL_ID'));

PLAN_HASH_VALUE SQL_ID
--------------- -------------
     1394742193 5cs5a166wqdq8

SELECT
   sql_id
  ,plan_hash_value
  ,sql_text
  ,first_load_time
  ,executions AS execs
  ,parsing_schema_name
  ,elapsed_time / 1000000 AS elapsed_time_secs
  ,cpu_time / 1000000 AS cpu_time_secs
  ,buffer_gets
  ,disk_reads
  ,direct_writes
  ,rows_processed
  ,fetches
  ,optimizer_cost
  --,sql_plan
FROM TABLE(DBMS_SQLTUNE.SELECT_SQLSET(sqlset_name => 'STS_&SQL_ID'));

8.Finally Load SQL Plan from STS (AWR History) using good plan Hash Value.

DECLARE
  my_plans pls_integer;
BEGIN
  my_plans := DBMS_SPM.LOAD_PLANS_FROM_SQLSET(
    sqlset_name => 'STS_&SQL_ID', 
    basic_filter=>'plan_hash_value = ''&p_good_plan_hash''');
END;
/

9.Check your loaded plan from baseline.

SELECT SQL_HANDLE,SQL_TEXT FROM SYS.SQL$TEXT WHERE UPPER(SQL_TEXT) LIKE UPPER('&p_sql_text');
SQL_HANDLE           SQL_TEXT                                          
-------------------- --------------------------------------------------
SQL_85423373d8eb4f5a SELECT mo.mfgordername, ot.ordertypename, matb.p  

SELECT * FROM dba_sql_plan_baselines WHERE SQL_HANDLE='&p_sql_handle' AND CREATED > SYSDATE-1;
SQL_HANDLE           SQL_TEXT                                           PLAN_NAME                      CREATOR  ORIGIN       PARSING_SCHEMA_NAME  ENABLED ACCEPTED
-------------------- -------------------------------------------------- ------------------------------ -------- ------------ -------------------- ------- ----
SQL_85423373d8eb4f5a SELECT mo.mfgordername, ot.ordertypename, matb.p   SQL_PLAN_8ahjmfgcfqmuuabea6752 SYS      MANUAL-LOAD  ELESMWIP             YES     YES

10.(Optional) drop the sql plan baseline if not needed anymore.

declare
  v_sql_plan_id  pls_integer;
begin
  v_sql_plan_id := dbms_spm.drop_sql_plan_baseline(
    sql_handle => 'SQL_85423373d8eb4f5a',
    plan_name => 'SQL_PLAN_8ahjmfgcfqmuu29d92161');
end;
/