473,799 Members | 2,711 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL --- Group Statement

jim
Hi,

I was wondering if anyone out there can help me with this SQL problem:

I have a database that has two tables: EMPLOYEE and JOB_TITLE

The EMPLOYEE Table consists of a salary and job_title _code columns,
among many others; the JOB_TITLE table contains job_title_code column,
among many others.

The SQL problem is: Select the employees' last names and Group them by
Salary within their job_title_code. I am new to SQL statements and
kinda puzzled on how to solve this problem. I would appreciate any help
I can get on this. Thanks a lot in advance.

Mar 21 '06 #1
1 1701

"jim" <ja************ **@yahoo.com> wrote in message
news:11******** **************@ u72g2000cwu.goo glegroups.com.. .
Hi,

I was wondering if anyone out there can help me with this SQL problem:

I have a database that has two tables: EMPLOYEE and JOB_TITLE

The EMPLOYEE Table consists of a salary and job_title _code columns,
among many others; the JOB_TITLE table contains job_title_code column,
among many others.

The SQL problem is: Select the employees' last names and Group them by
Salary within their job_title_code. I am new to SQL statements and
kinda puzzled on how to solve this problem. I would appreciate any help
I can get on this. Thanks a lot in advance.


First, you _do_ mean Access/Jet SQL, don't you? If you are looking for
"generic" SQL or SQL for some other database engine, you'll need to find the
appropriate newsgroup.

Secondly, if it were _my_ class problem, I'd use the Query Builder: Add the
two tables, join them on job_title_code, drag down the Job_Title_Code,
Salary Fields, and Last Name Fields (in that order!). I'd set Sort to
Ascending under Job_Title_Code.

Third, then I would go ask my teacher "Do you really want this Grouped By
salary, so that the Names do not show, or do you really want them Ordered By
salary, so that the Names do show?" If the teacher answers, Yes, I want them
Grouped by salary, then, click View | Totals and set Group By under Salary,
and play around with that. Change to SQL View and copy the SQL to whatever
medium you are submitting the assignement. If the teacher answers, No, I
want them Ordered By Salary, then just set Sort to Ascending under Salary...

Fourth, if it were "real life", I'd assume it meant Order By, and if so, I'd
also Sort by the Last Name, and First Name, both Ascending, as well.

Fifth, see the FAQ at http://www.mvps.org/access/netiquette.htm: we are not
here to do your homework for you. Consider that you caught me "in a weak
moment," that caused me to do more than we would usually do.

Larry Linson
Microsoft Access MVP
Larry Linson
Microsoft Access MVP

Mar 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6386
by: chowda | last post by:
trying to get to the bottom of this for some time...... eventually to be used with asp. heres the problem the following rather complex SQL statement works fine via query analyser: SELECT TOP 100 tbl_LevelDetail.nvchLevelName AS DataLevelName, MAX(CASE tintDataFieldId WHEN '1' THEN CAST(nvchData AS int) ELSE 0
4
28827
by: Chad Richardson | last post by:
I've always been mistified why you can't use a column alias in the group by clause (i.e. you have to re-iterate the entire expression in the group by clause after having already done it once in the select statement). I'm mostly a SQL hobbiest, so it's possible that I am not doing this in the most efficient manner. Anyone care to comment on this with relation to the following example (is there a way to acheive this without re-stating the...
4
1610
by: ree32 | last post by:
I know when you are using group by functions you have to include all the columns in the GROUP BY clause. But what I am having problems when using a case statement to determine whether to sum of not a column. eg. SELECT Country, Case WHEN Age<15 THEN Sum(Income) ELSE NULL END AS YouthIncome, Case WHEN Age>65 THEN Sum(Income) ELSE NULL END AS PensionIncome FROM WORLDTABLE
8
1539
by: | last post by:
hi, i have a table( tblUpdate) with the following fields UpdateID, UpdateDate, ActionID UpdateID is the primary key ActionID is a foreign key i want to find the latest (by date) update of a particluar action.
5
14294
by: Amadelle | last post by:
Hi All and thanks in advance, I was wondering what is the best way of grouping data in a dataset. Like using a "Group By" clause in Sql statements. I was thinking of using XML but I don't even know how to do grouping in XML. I have a dataset table which i would like to supposedly run the following sql statement on: Select UserID from tblAccounts
1
2855
by: A_PK | last post by:
I got one field, NOTE, its type is Ntext field. I have problem when query the statement using GROUP BY, could some pls kindly guide me. please found the sql query below... SELECT tblParent.indexno, tblParent.custno, tblParent.compname, tblParent.tt, tblParent.ordnotes FROM tblParent INNER JOIN tblChild ON tblParent.tid = tblChild.tid
1
2754
by: jatinder.saundh | last post by:
Hi, How do I give create database privielege to a specific user/group at a particular db2 instance ? I read about various authorities like SYSCTRL etc. but I am interested in giving only Create database privilege. I also came across GRANT <system privilege statement and it seems I can execute following statement to achieve what I want, GRANT CREATEDBA to <authorization-name>
0
945
by: wbarona | last post by:
Hello everyone, Could you please provide me with some assistance on how to group by a SQL statement when a selected column comes from a subquery. Here is an example of the SQL statement I am trying to write. I don't know what to add to the group by command in order to make it work. Thanks for your help and guidance select sa.sa_type_cd, nvl((select bsegitem.item_cnt from ps_ci_bseg bseg,
1
1898
by: hstello | last post by:
I have a rather simple SQL statement, but I can't get it to work properly. I have four columns in the activities table "LoginID", "StartDateTime", "StopDateTime", and "ProjectID". In a second table, Projects, I have "ProjectID" and "ProjectName". The goal of the SQL statement is to join the two ProjectID together, and get the difference in the stop and start time and any projects that are the same, sum or group them together. My SQL statement...
3
3868
by: ylekot88 | last post by:
Hi I am a student, I am trying to figure this out. I am trying to run a select statement that is asking for customer#, date, and total price of each order. ensure results are in chronological order based upon order date. When I run the following with just a group by clause, it works. If I add order by orderdate, I get an error message that states SQL Error: ORA-00979: not a GROUP BY expression. Why is the order by clause giving me a...
0
9550
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,...
0
10495
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10269
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10032
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 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...
0
9085
agi2029
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 project—planning, coding, testing, and deployment—without 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...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4148
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
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2942
bsmnconsultancy
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.