Queries have an associated payment transaction that will compensate the particular node that processes and responds to the query. The value of this payment transaction will go from the client sending the query to the node in question. To determine an appropriate value for this payment, a client can first send a version of the query but stipulate it desires not the actual response, but rather just the cost for that query. This type of COST_ANSWER query is free to the client.
The client can take the returned COST_ANSWER value and insert it as the value of the payment transaction for a real query.This payment transaction will also have an associated transaction fee - distinct from the value of the payment itself. The net cost to the client for a query is then the sum of the payment value (which goes from client to the node) and the transaction fee for the payment transaction (which goes from client to the node & network).
Clients should be aware that the full value of a payment transaction for a query will be processed - there is no protection against overpayment as there is for transactions.