-
Very urgent Greatest and least functions
I have to to find the greatest and least values from the set of values which are from the different columns.
Eg. Select greatest(tab1.date1, tab2.date2), least(tab1.date3, tab2.date4)
from tab1, tab2
where....
tab1 and tab2 are the tables and
date1, date3 are the columns from tab1
date2, date4 are the columns from tab2
Is there any easy way to do this in SQL server ?
MAX and MIN will not work here as these are not the max and min from the same column they are from the different tables and columns.
Thanks
-
Very urgent Greatest and least functions (reply)
if you are using sql 2k you can write a UDF that can give you what you need.
------------
sonali at 4/6/01 8:33:31 AM
I have to to find the greatest and least values from the set of values which are from the different columns.
Eg. Select greatest(tab1.date1, tab2.date2), least(tab1.date3, tab2.date4)
from tab1, tab2
where....
tab1 and tab2 are the tables and
date1, date3 are the columns from tab1
date2, date4 are the columns from tab2
Is there any easy way to do this in SQL server ?
MAX and MIN will not work here as these are not the max and min from the same column they are from the different tables and columns.
Thanks
-
Very urgent Greatest and least functions (reply)
How do you do that ? Do you have syntax even brief ?
thanks
------------
at 4/6/01 8:42:06 AM
if you are using sql 2k you can write a UDF that can give you what you need.
------------
sonali at 4/6/01 8:33:31 AM
I have to to find the greatest and least values from the set of values which are from the different columns.
Eg. Select greatest(tab1.date1, tab2.date2), least(tab1.date3, tab2.date4)
from tab1, tab2
where....
tab1 and tab2 are the tables and
date1, date3 are the columns from tab1
date2, date4 are the columns from tab2
Is there any easy way to do this in SQL server ?
MAX and MIN will not work here as these are not the max and min from the same column they are from the different tables and columns.
Thanks
-
Very urgent Greatest and least functions (reply)
Sonali, try this.
SET NOCOUNT ON
SELECT MAX(tab1.date1) as MaxCol, MIN(tab1.date3) as MinCol
INTO #temp
FROM tab1
UNION
SELECT MAX(tab2.date2), MIN(tab2.date4)
FROM tab2
SELECT MAX(MaxCol), MIN(MinCol) FROM #temp
Hope this helps,
Karl
------------
sonali at 4/6/01 8:33:31 AM
I have to to find the greatest and least values from the set of values which are from the different columns.
Eg. Select greatest(tab1.date1, tab2.date2), least(tab1.date3, tab2.date4)
from tab1, tab2
where....
tab1 and tab2 are the tables and
date1, date3 are the columns from tab1
date2, date4 are the columns from tab2
Is there any easy way to do this in SQL server ?
MAX and MIN will not work here as these are not the max and min from the same column they are from the different tables and columns.
Thanks
-
Very urgent Greatest and least functions (reply)
thanks a lot
------------
Karl at 4/6/01 9:07:47 AM
Sonali, try this.
SET NOCOUNT ON
SELECT MAX(tab1.date1) as MaxCol, MIN(tab1.date3) as MinCol
INTO #temp
FROM tab1
UNION
SELECT MAX(tab2.date2), MIN(tab2.date4)
FROM tab2
SELECT MAX(MaxCol), MIN(MinCol) FROM #temp
Hope this helps,
Karl
------------
sonali at 4/6/01 8:33:31 AM
I have to to find the greatest and least values from the set of values which are from the different columns.
Eg. Select greatest(tab1.date1, tab2.date2), least(tab1.date3, tab2.date4)
from tab1, tab2
where....
tab1 and tab2 are the tables and
date1, date3 are the columns from tab1
date2, date4 are the columns from tab2
Is there any easy way to do this in SQL server ?
MAX and MIN will not work here as these are not the max and min from the same column they are from the different tables and columns.
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|