How could i join this two queries?
--Declare both of your CTE first
WITH Numbered AS
(
SELECT
    B.id,
    B.masahat,
    B.tozihat,
    mahsol_name = G.mahsolname,
    ghate_code = G.ghate_code,
    M.cheshme,
    rn = ROW_NUMBER() OVER (
        PARTITION BY B.id
        ORDER BY G.id)
FROM bahrebardarighate AS B
JOIN ghatemanabeabi AS G
    ON B.id = G.bahrebardarighate_id
JOIN manabeabi AS M
    ON M.id = G.manabeabi_id
),--Separating the two CTE declarations
Numbered2 AS
(
SELECT
    A.id,
    A.bahrebardarighate_id,
    fullname = S.fullname,
    nationalcode = S.nationalcode,
    rn = ROW_NUMBER() OVER (
        PARTITION BY A.id
        ORDER BY S.id)
FROM ghate AS A
JOIN shoraka AS S
    ON A.id = s.ghate_id
)


--Then your select/UNION statement goes here, ensuring the two selects have the same number of columns and datatypes.