473,395 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

why don't group by work????

11
there are three tables i want to query i use the following statement

SELECT dbo.t_student_course.StudentId,dbo.t_books.book_na me
FROM dbo.t_student_course , dbo.t_students , dbo.t_books, dbo.t_groups
WHERE dbo.t_books.book_id = dbo.t_student_course.book_id
AND dbo.t_books.book_id = dbo.t_student_course.book_id AND dbo.t_student_course.StudentId = dbo.t_students.Student_ID
Group by dbo.t_student_course.StudentId, dbo.t_books.book_name

i got the following result

Student_id book_name
========= ========
4 City
5 City
3 Detective
5 Detective
1 PC
3 PC


when i use the following statement

SELECT dbo.t_student_course.StudentId
FROM dbo.t_student_course , dbo.t_students , dbo.t_books, dbo.t_groups
WHERE dbo.t_books.book_id = dbo.t_student_course.book_id
AND dbo.t_books.book_id = dbo.t_student_course.book_id AND dbo.t_student_course.StudentId = dbo.t_students.Student_ID
Group by dbo.t_student_course.StudentId


i got the following result


Student_id
=========
1
3
4
5

i want to get the following reult

Student_id book_name
========= ========
4 City
5 City
3 Detective
1 PC


what i should do to get the prevoius result. why don't group by work????

thanks for your help
Jun 30 '06 #1
1 1657
Banfa
9,065 Expert Mod 8TB
I do not think the group by clauses in either statement as you are not using an summary functions (like COUNT, SUM, AVG etc).

In the second statement you removed dbo.t_books.book_name from the SELECT statement, try

Expand|Select|Wrap|Line Numbers
  1. SELECT dbo.t_student_course.StudentId, dbo.t_books.book_name
  2. FROM dbo.t_student_course , dbo.t_students , dbo.t_books, dbo.t_groups
  3. WHERE dbo.t_books.book_id = dbo.t_student_course.book_id
  4. AND dbo.t_books.book_id = dbo.t_student_course.book_id AND dbo.t_student_course.StudentId = dbo.t_students.Student_ID
  5.  
Jun 30 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
3
by: Philip Herlihy | last post by:
I'm using a number of hyperlinks on an Intranet I'm developing which refer to documents on a network server. The URLs I'm using have the form: file://<server>/<path>/<file>.pdf <server> is an...
1
by: Jarrod | last post by:
Hallo, Have just created a small ASP .Net App with VS 2003 for the first time in years. After Building a release I proceed and uploaded my folder onto the wwwroot. The aspx pages just throw an...
7
by: Sameh Ahmed | last post by:
Hello there IsInrole gives ya the means to check if the current or impersonated user belongs to a specific windows role or group. is there a way to do the same without using ADSI to check if...
12
by: Bill Moran | last post by:
Hey all. I've hit an SQL problem that I'm a bit mystified by. I have two different questions regarding this problem: why? and how do I work around it? The following query: SELECT GCP.id,...
5
by: Edward Low | last post by:
Hi, I am having ASP with the following code to access the file with windows scripting host. The page run on local server IIS 5.1 on Win XP Pro SP2. The IE never show me any error with this, but...
0
by: U S Contractors Offering Service A Non-profit | last post by:
" Visionary Dreams " " Leaving New york City leaving to go " GOD noes were i Don't "
1
by: Jahamos | last post by:
Background: I have copy and pasted an Excel flowchart into a Dreamweaver html page. I created a frame on the top of the page as a viewer. I created hotspot links over the flowchart items. Each...
2
beacon
by: beacon | last post by:
Hi everybody, I have a form that has a combo box that asks the user to select the program they work on. Once the user selects the program, a SQL statement populates the row source for 4 staff...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.