T-SQL to Exclude the primary from List of AOAG Replicas I am working on a task for which I need to exclude primary from the list .Can someone please help me to fix it.

select primary_replica  from sys.dm_hadr_availability_group_states  


The above command gives Primary replica of AOAG.

select replica_server_name from sys.dm_hadr_availability_replica_cluster_states


The above command gives list of replicas of complete AOAG.

Now,I want to exclude primary_replica from the replica_server_name and I Want to see only secondary replicas.

So far I tried this but no luck.

select replica_server_name AS SecondaryReplicas from sys.dm_hadr_availability_replica_cluster_states INNER JOIN 
sys.dm_hadr_availability_group_states ON sys.dm_hadr_availability_group_states.group_id= sys.dm_hadr_availability_group_states.group_id  


Thanks in advance
You could adapt the query from this link (which is looking for PRIMARY replicas) to look for secondary replicas.  Example below:

IF SERVERPROPERTY('IsHadrEnabled') = 1
BEGIN
    SELECT AGC.NAME -- Availability Group
        ,RCS.replica_server_name -- SQL cluster node name
        ,ARS.role_desc -- Replica Role
        ,AGL.dns_name -- Listener Name
    FROM sys.availability_groups_cluster AS AGC
    INNER JOIN sys.dm_hadr_availability_replica_cluster_states AS RCS ON RCS.group_id = AGC.group_id
    INNER JOIN sys.dm_hadr_availability_replica_states AS ARS ON ARS.replica_id = RCS.replica_id
    INNER JOIN sys.availability_group_listeners AS AGL ON AGL.group_id = ARS.group_id
    WHERE ARS.role_desc = 'SECONDARY'
END