Disclosed is a method for processing a query in a database management system (DBMS). The method includes: receiving a main query including a subquery; identifying an indication to independently manage a processing result for the subquery in the received main query by parsing the received main query—the indication including storing type information for the processing result of the subquery; determining a storing type for independently storing the processing result for the subquery based on the indication; and storing the processing result for the subquery independently from the processing result for the main query while performing processing for the main query according to the determined storing type.