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

Closed Thread
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:
  #1  
Old May 12th, 2005, 01:39 AM
sap sap is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 53 sap User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 46 m 10 sec
Reputation Power: 4
max querie help

hi, i had 2 make a database for an assignment and write up queries to retirve data from iti am having some problems with the queries

here is my querie
SELECT C.ClientName, co.clientid, Count(*) as Total_Orders
From Client C ,ClientOrder CO
WHERE C.ClientID = CO.ClientID
group by c.clientname, co.clientid
ORDER BY COUNT(c.clientname) DESC;

and here is the result of it
CLIENTNAME CLIENTID TOTAL_ORDERS
------------------------------ ---------- ------------
John SMith 1 5
Tree corp 7 4
ford 3 2
maccas 2 2
Simpsons 4 2
stardust 5 1
nuclear plant 6 1
i need to display only the maximum and not all of them , all i need is the first one 2 show, or if you know how i can improve the querie please let me know

Reply With Quote
  #2  
Old May 12th, 2005, 05:49 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,784 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 4 Days 21 h 42 m 49 sec
Reputation Power: 37
Code:
SELECT top 1 C.ClientName, co.clientid, Count(*) as Total_Orders
From Client C ,ClientOrder CO
WHERE C.ClientID = CO.ClientID
group by c.clientname, co.clientid
ORDER BY COUNT(c.clientname) DESC

Reply With Quote
  #3  
Old May 12th, 2005, 07:25 AM
sap sap is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 53 sap User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 46 m 10 sec
Reputation Power: 4
thanx for the rpely but im getting this error
ERROR at line 1:
ORA-00923: FROM keyword not found where expected
its pointing at 1

Reply With Quote
  #4  
Old May 12th, 2005, 08:22 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,784 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 4 Days 21 h 42 m 49 sec
Reputation Power: 37
Why are you posting queries relating to Oracle in a forum dedicated to Microsoft SQL server?

Reply With Quote
  #5  
Old May 12th, 2005, 09:14 AM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,308 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 5 h 17 m 10 sec
Reputation Power: 48
This seems to be the Oracle Forum...

Pabloj: I moved the thread to the right forum.

Last edited by pabloj : May 12th, 2005 at 09:16 AM.

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsDatabasesOracle Development > max querie 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


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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT