473,883 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

why don't group by work????

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

SELECT dbo.t_student_c ourse.StudentId ,dbo.t_books.bo ok_name
FROM dbo.t_student_c ourse , dbo.t_students , dbo.t_books, dbo.t_groups
WHERE dbo.t_books.boo k_id = dbo.t_student_c ourse.book_id
AND dbo.t_books.boo k_id = dbo.t_student_c ourse.book_id AND dbo.t_student_c ourse.StudentId = dbo.t_students. Student_ID
Group by dbo.t_student_c ourse.StudentId , dbo.t_books.boo k_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_c ourse.StudentId
FROM dbo.t_student_c ourse , dbo.t_students , dbo.t_books, dbo.t_groups
WHERE dbo.t_books.boo k_id = dbo.t_student_c ourse.book_id
AND dbo.t_books.boo k_id = dbo.t_student_c ourse.book_id AND dbo.t_student_c ourse.StudentId = dbo.t_students. Student_ID
Group by dbo.t_student_c ourse.StudentId

i got the following result


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 1668
9,065 Recognized Expert Moderator Expert
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.boo k_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
Jun 30 '06 #2

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

Similar topics

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 Smarty-2.6.7.tar.gz on a system running WindowsXP SP2. Apache and PHP tested out fine. After adding Smarty, I ran the following http://localhost/testphp.php
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 UNC path, like: \\hostname They work perfectly in IE, but not in Opera or Firefox. I can't see any reason why not - is the form correct? Any other ideas? --
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 error. The Htm pages are visible. The error page is the plain old application error page with info on how to set the customErrors in the webconfig. I cant even redirect to errordefaul page as that doesn´t work either. The WebServer is a MS2003...
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 "domain\user" belongs to "domain\group"? the reason is, when getting the "memberof" property of a user, then checking if it contains the desired group or not. this will only work if the user is a member of the group itself but not when he is a member...
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, GCP.Name FROM Gov_Capital_Project GCP,
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 will keep access the page for very long. This code is running fine on other system. strFilePath = Server.MapPath("\db\counter.txt") Set objFSO = Server.CreateObject("Scripting.FileSystemObject") objFSO.OpenTextFile(strFilePath, ForReading)
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 "
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 hotspot link should open a new anchor link in the top frame which references a different webpage. Problem: It works fine in Firefox. When clicking on the hotspots I get the appropriate html page anchor link to reference my html page and it correctly...
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 member combo boxes. I have an option group that has 4 option buttons for the user to indicate how many staff members to include. Once the user selects one of the option buttons, the appropriate number of combo boxes become enabled and contain the...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.