The ordinary adjective котћрый agrees with its antecedent (in italics, below) in gender and number, but its case depends on its function in its own clause. It means 'who; which' and is mostly used to introduce clauses.
Ї дџмал, вІ разговђривали с другќм Петрћм Ильичћм, у котћрого (Gen.) нљт женІ. I thought you were talking with another Peter Ilyich,who doesn't have a wife.
Ї дџмал, вІ разговђривали с другћй Нќной Ильќничной, у котћрой (Gen.) нљт мџжа. I thought you were talking with another Nina Ilyinichna, who doesn't have a husband.
Дђйте мнљ кнќгу, котћрая (Nom.) лежќт на столљ. Give me the book (which is) lying on the table.
Дђйте мнљ нћж, котћрый (Nom.) лежќт на столљ. Give me the knife (which is) lying on the table.