Home » Other » Client Tools » Finding Largest Among Matrix
|
Re: Finding Largest Among Matrix [message #25927 is a reply to message #25926] |
Tue, 27 May 2003 07:08 |
|
Maaher
Messages: 7065 Registered: December 2001
|
Senior Member |
|
|
Here's a few possibilities:SQL> select max(col1) col1
2 , max(col2) col2
3 , max(col3) col3
4 , max(col4) col4
5 , max(col5) col5
6 , max(col6) col6
7 , max(col7) col7
8 , max(col8) col8
9 , max(col9) col9
10 , max(col10) col10
11 from test;
COL1 COL2 COL3 COL4 COL5 COL6 COL7
---------- ---------- ---------- ---------- ---------- ---------- ----------
COL8 COL9 COL10
---------- ---------- ----------
20 240 4 9 100 29 53
66 4 86
SQL> SELECT max(n) n
2 from ( select max(col1) n
3 from test
4 union
5 select max(col2) n
6 from test
7 union
8 select max(col3) n
9 from test
10 union
11 select max(col4) n
12 from test
13 union
14 select max(col5) n
15 from test
16 union
17 select max(col6) n
18 from test
19 union
20 select max(col7) n
21 from test
22 union
23 select max(col8) n
24 from test
25 union
26 select max(col9) n
27 from test
28 union
29 select max(col10) n
30 from test
31* ) x
SQL> /
N
----------
240
SQL> select greatest(max(col1)
2 ,max(col2)
3 ,max(col3)
4 ,max(col4)
5 ,max(col5)
6 ,max(col6)
7 ,max(col7)
8 ,max(col8)
9 ,max(col9)
10 ,max(col10)
11 ) ok
12* From test
SQL> /
OK
----------
240
SQL>
MHE
|
|
|
Re: Finding Largest Among Matrix [message #25928 is a reply to message #25926] |
Tue, 27 May 2003 07:10 |
Art Metzer
Messages: 2480 Registered: December 2002
|
Senior Member |
|
|
quote from Chidambar Rajpurohit:
----------------------------------------------------------------------
I'm having a table as Temp. In which 10 columns all are numbers. Ive inserted 10 rows. Now i wanted to find out the Maximum number in that matrix.
----------------------------------------------------------------------
SQL> SELECT col_01
2 , col_02
3 , col_03
4 , col_04
5 , col_05
6 , col_06
7 , col_07
8 , col_08
9 , col_09
10 , col_10
11 FROM t
12 /
COL_01 COL_02 COL_03 COL_04 COL_05 COL_06 COL_07 COL_08 COL_09 COL_10
---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
57 72 80 66 94 3 39 11 79 64
87 93 40 23 37 86 96 50 53 12
95 47 99 33 24 88 22 6 60 76
8 2 46 75 78 49 62 0 21 36
30 56 98 73 44 17 77 16 67 69
42 41 54 55 97 90 31 91 61 5
65 59 71 1 13 29 4 15 89 82
92 25 70 32 68 26 14 7 38 34
74 84 20 10 51 27 48 43 83 9
18 85 58 45 52 19 81 28 35 63
10 rows selected.
SQL> SELECT MAX(GREATEST(col_01
2 , col_02
3 , col_03
4 , col_04
5 , col_05
6 , col_06
7 , col_07
8 , col_08
9 , col_09
10 , col_10))
11 FROM t
12 /
MAX(GREATEST(COL_01,COL_02,COL_03,COL_04,COL_05,COL_06,COL_07,COL_08,COL_09,COL_10))
------------------------------------------------------------------------------------
<font color=red>99</font>
SQL> HTH,
A
|
|
|
Goto Forum:
Current Time: Sat Jan 18 11:28:39 CST 2025
|