Suppose I have a table Tab1 with attributes – a1, a2, … etc. None of the attributes are unique.
What will be the nature of the following query? Will it return a single row always?
SELECT a1, a2, sum(a3) FROM Tab1 GROUP BY a1, a2
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
GROUP BYreturns a single row for each unique combination of theGROUP BYfields. So in your example, every distinct combination of(a1, a2)occurring in rows ofTab1results in a row in the query representing the group of rows with the given combination of group by field values . Aggregate functions likeSUM()are computed over the members of each group.