Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Group by Function

Author  Topic 

hameedf
Starting Member

27 Posts

Posted - 2012-06-29 : 02:50:57
Hello Experts !

I have a query in which i sum the data and i dont want group the other column which is character suppose

Select sum(fee),student_name from student
where ...
Group by sum(fee)
order by student_name

Iam doing like that i dont want to group by student name ?

Thanks
hamedf

Hameed

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-06-29 : 03:32:37
[code]Select sum(fee),student_name from student
where ...
Group by sum(fee) student_name
order by student_name[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

hameedf
Starting Member

27 Posts

Posted - 2012-06-29 : 05:22:35
Thank you Khtan,

if i am joing two table and column name table1.column_1, table2.column

Select sum(table1.fee),table1.student_name as st1,table2.student_name as st2 from table1,table2
where ...
Group by table1.student_name
order by student_name

I dont want to group by table2.student_name so what should i do if i group by table2.student_name my results not correct?

Thanks
Hamedf



Hameed
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-06-29 : 06:15:14
how do you join these 2 table ? on student_name ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

hameedf
Starting Member

27 Posts

Posted - 2012-06-29 : 08:08:36
Select sum(table1.fee),table1.student_name as st1,table2.student_name as st2 from table1,table2
where table1.ITEM_ID=table2.ITEM_ID
Group by table1.student_name
order by student_name


Hameed
Go to Top of Page
   

- Advertisement -