Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


In --> Group By with Multiple columns...> how it will responds


In --> Group By with Multiple columns...> how it will responds

Author
Message
r.dilliprasad
r.dilliprasad
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 113
can any please help me...!

Thanks & Regards
Prasad Reddy
Lowell
Lowell
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14955 Visits: 38950
the title of your post "In --> Group By with Multiple columns...> how it will responds " is not enough for us to go by;
can you explain your question better? do you have a coded example that's not working as expected?

Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

r.dilliprasad
r.dilliprasad
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 113
query is

select col1, col2, col3.... from table

Group BY Colm, Coln

Here my question is :: while we take 2 or more colmuns in Group By..
Actually how it works
dgowrij
dgowrij
Valued Member
Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)

Group: General Forum Members
Points: 50 Visits: 75
Below is a basic example for Group By

CREATE TABLE #Studentcourseschedule(
Department int,
Courseid int,
studentid int)
go
insert into #Studentcourseschedule(Department, Courseid,studentid)
values(1,1,1)
,(1,2,1)
,(1,3,1)
,(1,1,5)
,(1,3,6)
,(1,1,7)
,(2,2,1)
,(2,1,2)
,(2,3,2)
go
select department, COUNT(studentid) Studentcount
from #Studentcourseschedule
group by department
order by Department
go
select department, courseid, COUNT(studentid) Studentcount
from #Studentcourseschedule
group by department,courseid
order by Department, Courseid


1st Query Result:
department Studentcount
1 6
2 3
2nd Query Result
department courseid Studentcount
1 1 3
1 2 1
1 3 2
2 1 1
2 2 1
2 3 1

In the first query the grouping is done only on Department, so it checks the no of students in each of the Department available in the table which is 1 and 2 in example
When we add another group by column on courseid, now it looks for the each course available under each department and displays count of the student in that department and course.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search