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:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old June 22nd, 2004, 05:57 AM
joyce joyce is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2001
Posts: 92 joyce User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 18 sec
Reputation Power: 7
select min(rate) and distinct(code)

what is wrong with my query??

select distinct ratecodeno, min (adult_rate) from twn_rate where productno=136 and database='twn_p_mgh' and (cvm_dip_id=0 or cvm_dip_id is null) group by adult_rate order by adult_rate

Reply With Quote
  #2  
Old June 22nd, 2004, 07:03 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,766 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 6 h 15 m 31 sec
Reputation Power: 37
What are you trying to do? Describe the table with some sample data and the expected result.

Reply With Quote
  #3  
Old June 22nd, 2004, 07:26 AM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 5
Your query is fine but you need some modification in it. For example when you are using any column with group function in SELECT clause then it must be appear in GROUP BY clause. Look at your query gain and find the difference.


SELECT distinct ratecodeno, min (adult_rate)
FROM twn_rate
WHERE productno=136
AND database='twn_p_mgh'
AND (cvm_dip_id=0 or cvm_dip_id is null)
GROUP BY ratecodeno
ORDER by adult_rate

Reply With Quote
  #4  
Old June 22nd, 2004, 09:28 PM
joyce joyce is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2001
Posts: 92 joyce User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 18 sec
Reputation Power: 7
does that means i need to have adult_rate in my group by also?? I tried this, but it didn't work
SELECT distinct ratecodeno, min (adult_rate)
FROM twn_rate
WHERE productno=136
AND database='twn_p_mgh'
AND (cvm_dip_id=0 or cvm_dip_id is null)
GROUP BY ratecodeno, adult_rate
ORDER by adult_rate

Reply With Quote
  #5  
Old June 22nd, 2004, 09:30 PM
joyce joyce is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2001
Posts: 92 joyce User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 18 sec
Reputation Power: 7
Quote:
Originally Posted by swampBoogie
What are you trying to do? Describe the table with some sample data and the expected result.

I would like to select all the record sort by adult_rate from cheapest to most expensive..

for eg my data,
ratecodeno adult_rate
1 100
1 50
2 150
3 50

so in this case, my desire output would be,
1 50
3 50
2 150

Reply With Quote
  #6  
Old June 23rd, 2004, 04:03 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,766 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 6 h 15 m 31 sec
Reputation Power: 37
Code:
SELECT ratecodeno, min (adult_rate) as lowRate
FROM twn_rate
WHERE productno=136
AND database='twn_p_mgh'
AND (cvm_dip_id=0 or cvm_dip_id is null)
GROUP BY ratecodeno
ORDER by lowRate

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > select min(rate) and distinct(code)


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 1 hosted by Hostway