More evidence of brain-damage... 
Author Message
 More evidence of brain-damage...

greetings - i have spent too much time in the dimly-lit backroom working on
old xbase-programs. i now would like to use the function i used to know as
MIN(a,b,c) to retrieve the smaller of a list of values. T-Sql merely smirks
at
me and points out that MIN(column) will give me the smallest value from a
named column. (stop that chuckling out there, you lot).
what function or method will give me what i so dearly desire? i would like
to
say MIN((normalhrs * hour_rate) * 26), 200000) and be told which of the
two values is smaller....
TIA
b clark at lrgh dot org


Fri, 06 Jan 2006 18:56:23 GMT
 More evidence of brain-damage...

Try

case  (normalhrs * hour_rate) * 26 < 200000 then (normalhrs * hour_rate) *
26 else 200000

Jun Fang

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.


Quote:
> greetings - i have spent too much time in the dimly-lit backroom working
on
> old xbase-programs. i now would like to use the function i used to know as
> MIN(a,b,c) to retrieve the smaller of a list of values. T-Sql merely
smirks
> at
> me and points out that MIN(column) will give me the smallest value from a
> named column. (stop that chuckling out there, you lot).
> what function or method will give me what i so dearly desire? i would like
> to
> say MIN((normalhrs * hour_rate) * 26), 200000) and be told which of the
> two values is smaller....
> TIA
> b clark at lrgh dot org



Fri, 06 Jan 2006 19:00:30 GMT
 More evidence of brain-damage...
There is no inbuilt function in T-SQL which allows you to do this directly.
You can use CASE expressions like:

SELECT CASE WHEN a > b THEN a ELSE b END AS "Max"

If there are three values, you'll have to change with nested CASEs or
multiple IF...ELSE.. accordingly. If there is a bunch of values, you can
create a fake table & do :

SELECT MAX(col)
  FROM ( SELECT 'a' UNION
         SELECT 'b' UNION
         SELECT 'c' ...) D (col) ;

--
- Anith
( Please reply to newsgroups only )



Fri, 06 Jan 2006 19:00:39 GMT
 More evidence of brain-damage...
In addition to what Anith has posted, you may want to return NULL if one of
your values is NULL. That's how XBase (at least FoxPro) works. If you need
to propagate NULL values here's an example:

CREATE TABLE SomeValues (X INTEGER PRIMARY KEY, Y INTEGER NULL, Z INTEGER
NULL)

INSERT INTO SomeValues VALUES (1,2,3)
INSERT INTO SomeValues VALUES (2,1,3)
INSERT INTO SomeValues VALUES (3,2,NULL)

SELECT *,
 (SELECT MIN(v)
  FROM (SELECT X AS v UNION ALL SELECT Y UNION ALL SELECT Z) m
  HAVING COUNT(v)=COUNT(*) -- Result only if all values are non-NULL
 )
 AS minimum,
 (SELECT MAX(v)
  FROM (SELECT X AS v UNION ALL SELECT Y UNION ALL SELECT Z) m
  HAVING COUNT(v)=COUNT(*) -- Result only if all values are non-NULL
 )
 AS maximum
 FROM SomeValues

--
David Portas
------------
Please reply only to the newsgroup
--


Quote:
> greetings - i have spent too much time in the dimly-lit backroom working
on
> old xbase-programs. i now would like to use the function i used to know as
> MIN(a,b,c) to retrieve the smaller of a list of values. T-Sql merely
smirks
> at
> me and points out that MIN(column) will give me the smallest value from a
> named column. (stop that chuckling out there, you lot).
> what function or method will give me what i so dearly desire? i would like
> to
> say MIN((normalhrs * hour_rate) * 26), 200000) and be told which of the
> two values is smaller....
> TIA
> b clark at lrgh dot org



Fri, 06 Jan 2006 19:22:28 GMT
 More evidence of brain-damage...
greetings - and an extra large 'Thanks' for all responses. that is  just
what i was looking for.
bc


Quote:
> greetings - i have spent too much time in the dimly-lit backroom working
on
> old xbase-programs. i now would like to use the function i used to know as
> MIN(a,b,c) to retrieve the smaller of a list of values. T-Sql merely
smirks
> at
> me and points out that MIN(column) will give me the smallest value from a
> named column. (stop that chuckling out there, you lot).
> what function or method will give me what i so dearly desire? i would like
> to
> say MIN((normalhrs * hour_rate) * 26), 200000) and be told which of the
> two values is smaller....
> TIA
> b clark at lrgh dot org



Fri, 06 Jan 2006 19:33:22 GMT
 
 [ 5 post ] 

 Relevant Pages 

1. Brain damaging question: recursive SELECT statement

2. Time Zones and Brain Damage :)

3. Viewpoint Pro Brain-Damaged?

4. Evidence of MicroSoft Plundering Sybase Code(still)

5. ** EVIDENCE ELIMINATING SOFTWARE** dddddddddddd 7550 [1/2]

6. ** EVIDENCE ELIMINATING SOFTWARE** dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd 2472 [1/2]

7. //////////////|||||||||| Evidence Eliminator ||||||||||\\\\\\\\\\\\\\\\\ . 469

8. 2.6 - what evidence it has been installed?

9. evidence eliminator software


 
Powered by phpBB® Forum Software