help in simple sql query:

This is a discussion on help in simple sql query: within the Oracle forums in Oracle Database category; i want to access all the data in the row of min(time_value) and max(time_value) in a single query: below the sql i wrote but not working: select * from std_detail where time_value in ( select max(time_value),min(time_value) from std_detail) ---------------------------------------------------------------------- plz help me...

Go Back   Database Forum > Oracle Database > Oracle

Database Forums

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 07-01-2008, 08:42 AM
Default help in simple sql query:

i want to access all the data in the row of min(time_value) and max(time_value) in a single query:

below the sql i wrote but not working:

select * from std_detail where time_value in ( select max(time_value),min(time_value) from std_detail)

----------------------------------------------------------------------

plz help me
Reply With Quote
  #2  
Old 07-08-2008, 04:43 PM
Default Re: help in simple sql query:

There are better ways but you need to give more information about your problem before I can give you the code.

Here is one simple way to get your answer:

SELECT std_detail.*
FROM std_detail
WHERE std_detail.time_value = (SELECT MAX(std_detail.time_value)
FROM std_detail)
OR std_detail.time_value = (SELECT MIN(std_detail.time_value)
FROM std_detail);
Reply With Quote
  #3  
Old 11-15-2008, 05:22 PM
Default Re: help in simple sql query:

Quote:
Originally Posted by ali560045 View Post
i want to access all the data in the row of min(time_value) and max(time_value) in a single query:

below the sql i wrote but not working:

select * from std_detail where time_value in ( select max(time_value),min(time_value) from std_detail)

----------------------------------------------------------------------

plz help me
your query will always return 2 rows unless untill both the max and min are the same.
Reply With Quote
  #4  
Old 11-17-2008, 02:38 PM
Default Re: help in simple sql query:

SELECT std_detail.*
FROM std_detail
WHERE std_detail.time_value = (SELECT MAX(std_detail.time_value)
FROM std_detail)
union
SELECT std_detail.*
FROM std_detail
WHERE std_detail.time_value = (SELECT MIN(std_detail.time_value)
FROM std_detail)
Reply With Quote
Reply


Thread Tools
Display Modes



All times are GMT -4. The time now is 04:33 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Integrated by bbpixel2008 :: jvbPlugin R1013.368.1

Search Engine Friendly URLs by vBSEO 3.1.0
vB Ad Management by =RedTyger=
In an effort to better serve ads to our visitors, cookies are used on Mydatabasesupport.com. For more information, check out our Privacy Policy.