If my query was rejected by an agent, does it make sense to query a different agent in the same agency?
Unless the agency has a "query one/query all" policy, yes.
Here's how you tell if the agency has a "query one/query all" policy?
(1) you query a central email such as Queries@BestSellerAgency.com
Here's an example of that:
All queries should be sent to Submissions(at)KnightAgency(dot)net.....
Queries must be addressed to a specific agent. Please do not query multiple agents. To determine which member of our team would be most appropriate for your project, visit our “About Us” page.
(2) the agency website says one and done.
Here's an example from the Andrea Brown Agency:
Visit the agents' bios page and choose only one agent to whom you will submit your e-query.
Now, here's an example from FPLM which is NOT one and done, and not query one/query all:
Each FinePrint agent has particular interests in fiction, and accepts submission in the genres listed on their bio pages.
If we’re interested, we will ask to see a few chapters or the full manuscript.
Notice that it does NOT say "one agent"
But your real question is: if one agent at an agency says no, and the agency is ok with querying other agents, is it worth it? Yes it is. We work under the same letterhead but we don't have identical tastes. No one of course has ever told me they don't like a book I've sold but that's more in fear of the mortal peril that would ensue, than an expression of differing taste.