Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
  #1  
Old September 17th, 2003, 02:22 PM
KLgirl KLgirl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 31 KLgirl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Unhappy Join Counting, please anyone help!

I have two tabels:
Column Name Data Type
StudentID NUMBER(5,0) NOT NULL
Name VARCHAR2(25)
Major VARCHAR2(15)
GPA NUMBER(6,3)


Column Name Data Type
StudentID NUMBER(5,0) NOT NULL
CourseNumber VARCHAR2(15) NOT NULL
CourseName VARCHAR2(25)
Semester VARCHAR2(10)
Year NUMBER(4,0)
Grade VARCHAR2(2)

The two things I need to do:
For each student, count the number of courses he or she has taken.

then modify the above query to only count CMIS courses (using a substring function on the coursenumber)

I tried a lot of different things, which didn't work. I am a beginner and if somebody can help me I would really, really appreciate it.

Reply With Quote
  #2  
Old September 18th, 2003, 08:36 AM
martysb martysb is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Austin, TX
Posts: 9 martysb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to martysb
I'm going to assume that the first table is called STUDENT, and the second is SCHEDULE. 'Cos that's what they look like.

select a.name, a.studentid, count(b.coursenumber)
from student a, schedule b
where a.studentid = b.studentid
group by a.studentid, a.name

will get you a list of students, each with the number of courses they've taken. In order to limit the courses you want to count, you simply add it to the where clause.

select a.name, a.studentid, count(b.coursenumber)
from student a, schedule b
where a.studentid = b.studentid
and substr(b.coursenumber,1,4) = '1234'
group by a.studentid, a.name

Or you can limit which student you're counting by major in the same fashion. I hope this helps get you started.

Oracle's documentation is notoriously difficult for beginners to find stuff in (okay, not just beginners), but still, I thought I'd give you the link to their sql reference section of their documentation site. May require registering for a free account.
http://download-west.oracle.com/doc.../a96540/toc.htm

I hope this helps, if not, come back and ask more questions.

Marty

Reply With Quote
  #3  
Old September 19th, 2003, 11:27 AM
KLgirl KLgirl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 31 KLgirl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Thank you

Hi Marty,
This worked like charm...thank you very much.
Might you be able to tell me what's wrong with these two statements?

GRANT SELECT
ON Students
TO FirstName LastName;


REVOKE SELECT
ON Students
FROM FirstName LastName;

Oracle doesn't like them :-) It says wrong ending, it's probably something simple that I am not seeing!

I appreciate your help...thanks again and I will check out that linke.
Natalie

Reply With Quote
  #4  
Old September 19th, 2003, 01:02 PM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,745 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 3 Days 19 h 49 m 39 sec
Reputation Power: 31
GRANT SELECT
ON Students
TO FirstName, LastName;

REVOKE SELECT
ON Students
FROM FirstName, LastName;

Reply With Quote
  #5  
Old September 19th, 2003, 02:51 PM
KLgirl KLgirl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 31 KLgirl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Hi,

If I separate the first and last name by commas, it complete disregards the last name

Thank you,
KLgirl

Reply With Quote
  #6  
Old September 19th, 2003, 08:33 PM
martysb martysb is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Austin, TX
Posts: 9 martysb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to martysb
Hmm, Oracle doesn't allow spaces in usernames. At least I think so. That said, I don't have access to a test system at the moment.

I'd try just putting the name in ticks, i.e.

grant select on students to 'Bob Smith';

Though, like I said, I don't think that you can have usernames with spaces in them. Without some doing, anyway. Are you sure that you're using the oracle username, and not an application user or something?

Again, I hope this gets you going in the right direction. If not, stop by and ask another question.

Marty

Reply With Quote
  #7  
Old September 20th, 2003, 02:38 AM
KLgirl KLgirl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 31 KLgirl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Thanks Marty,
Your input was most helpful. I was being an idiot...I had access to the user name of this person and totally forgot it. When I used the user name, it worked just fine.
Duhhhhh, sometimes I could kick myself

KLgirl

Reply With Quote
  #8  
Old September 22nd, 2003, 07:52 AM
martysb martysb is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Austin, TX
Posts: 9 martysb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to martysb
Hehe, that happens to the best of us... I'm glad it worked out for you.

Marty

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Join Counting, please anyone help!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway