January 21, 2015 at 7:18 am
Hi,
How can we write the query using groupby. I need to have group by only one column. Is it possible through subquery?
select col1, col2, col3
from testtable
group by col1.
January 21, 2015 at 7:26 am
Suppose
select col1, min(col2), max(col2) , count(col2)
from mytable
group by col1
returns 1 , -10, 5000, 1000
What do you mean, select col1, col2 ... ? Which col2 value?
January 21, 2015 at 7:28 am
ramana3327 (1/21/2015)
Hi,How can we write the query using groupby. I need to have group by only one column. Is it possible through subquery?
select col1, col2, col3
from testtable
group by col1.
Can you show is the homework question?
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
January 21, 2015 at 7:42 am
Use some aggregate function like MAX() , MIN() for col2 and col3, since on grouping multiple row would be shown as single row.
January 28, 2015 at 10:15 pm
You need to use any aggregate function on columns col2, col3 as these are not part of group by clause.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply