How to find max value in single row
i would like to know that,
how can i display maximum value among several values in a single row of table
example : i have to get value 5
among 1 2 3 4 5 values of same row.
Take a look at GREATEST function.
C.
Link to documentation added
Message was edited by:
cd
Similar Messages
-
How to find max value from a list of numbers stored in a varray?
hi,
Can any body help me to get the max value from a list of numbers stored in a varray?
thanks in advance....
regards
LaxmiNarsimhaYes. Could you post what you have tried before we start helping you in this?
-
How to concatenate the values in single row with images or colours
hi all,
i am apex 4.2,
i tried to execute a plsql query for the values concatenate two values into same column
example in my table
i am having teachers list one can teach two or three subjects
in table i am saving like
teacher_id teacher_name salary subjects
1 ram 5000 science,maths
2 gang 4000 maths,science,english
but my report should come like
teacher_id teacher_name salary subjects
1 ram 5000 science maths i have to highlighting these subjects with images or with different colors
2 gang 4000 maths english science
can any one help me please
thanks & regards
pavan
Edited by: Pavan on Apr 9, 2012 4:15 AM
Edited by: Pavan on Apr 9, 2012 4:22 AMFirst of all, i would split the subjects column.
If you for sure only need up to 3 subjects, you could make three columns subject1, subject2, subject3.
If you may have an indefinite number of subjects for each teacher, you might create a detail-table with the subjects for each teacher.
I also would create a list of values for the subjects, either based on static values or based on another table with the subjects allowed.
Now that the subject-names are fixed you could create a subject-image for each subject, named as the subject itself. Then you "construct" the image for each subject as
<img src="#APP_IMAGES##SUBJECT_NAME#.png"/> -
Hi,
How to find the average of table row values it should display in next row in libwindow/CVI
Please let me know the solution.There isn't a built-in function to perform calculations on thable cells. What you can do is to retrieve thable cells values and calculate the average by yourself.
To retrieve a bunch of cells in a single instruction you can use GetTableCellRangeVals: prerequisite for this function to work correctly is that cells are all included in a Rect structure (shortly, a rectangle) and are all of the same data type. See the help for the function for some explanations and the link to an example of its usage. In Cell range parameter you can pass VAL_TABLE_ROW_RANGE (row) macro to retrieve an entire row. See here for details.
Once you have retrieved cell values in an array, you can pass it to Mean function to calculate the average.
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos? -
How can i get all these values in single row with comma separated?
I have a table "abxx" with column "absg" Number(3)
which is having following rows
absg
1
3
56
232
43
436
23
677
545
367
xxxxxx No of rows
How can i get all these values in single row with comma separated?
Like
output_absg
1,3,56,232,43,436,23,677,545,367,..,..,...............
Can you send the query Plz!These all will do the same
create or replace type string_agg_type as object
2 (
3 total varchar2(4000),
4
5 static function
6 ODCIAggregateInitialize(sctx IN OUT string_agg_type )
7 return number,
8
9 member function
10 ODCIAggregateIterate(self IN OUT string_agg_type ,
11 value IN varchar2 )
12 return number,
13
14 member function
15 ODCIAggregateTerminate(self IN string_agg_type,
16 returnValue OUT varchar2,
17 flags IN number)
18 return number,
19
20 member function
21 ODCIAggregateMerge(self IN OUT string_agg_type,
22 ctx2 IN string_agg_type)
23 return number
24 );
25 /
create or replace type body string_agg_type
2 is
3
4 static function ODCIAggregateInitialize(sctx IN OUT string_agg_type)
5 return number
6 is
7 begin
8 sctx := string_agg_type( null );
9 return ODCIConst.Success;
10 end;
11
12 member function ODCIAggregateIterate(self IN OUT string_agg_type,
13 value IN varchar2 )
14 return number
15 is
16 begin
17 self.total := self.total || ',' || value;
18 return ODCIConst.Success;
19 end;
20
21 member function ODCIAggregateTerminate(self IN string_agg_type,
22 returnValue OUT varchar2,
23 flags IN number)
24 return number
25 is
26 begin
27 returnValue := ltrim(self.total,',');
28 return ODCIConst.Success;
29 end;
30
31 member function ODCIAggregateMerge(self IN OUT string_agg_type,
32 ctx2 IN string_agg_type)
33 return number
34 is
35 begin
36 self.total := self.total || ctx2.total;
37 return ODCIConst.Success;
38 end;
39
40
41 end;
42 /
Type body created.
[email protected]>
[email protected]> CREATE or replace
2 FUNCTION stragg(input varchar2 )
3 RETURN varchar2
4 PARALLEL_ENABLE AGGREGATE USING string_agg_type;
5 /
CREATE OR REPLACE FUNCTION get_employees (p_deptno in emp.deptno%TYPE)
RETURN VARCHAR2
IS
l_text VARCHAR2(32767) := NULL;
BEGIN
FOR cur_rec IN (SELECT ename FROM emp WHERE deptno = p_deptno) LOOP
l_text := l_text || ',' || cur_rec.ename;
END LOOP;
RETURN LTRIM(l_text, ',');
END;
SHOW ERRORS
The function can then be incorporated into a query as follows.
COLUMN employees FORMAT A50
SELECT deptno,
get_employees(deptno) AS employees
FROM emp
GROUP by deptno;
###########################################3
SELECT SUBSTR(STR,2) FROM
(SELECT SYS_CONNECT_BY_PATH(n,',')
STR ,LENGTH(SYS_CONNECT_BY_PATH(n,',')) LN
FROM
SELECT N,rownum rn from t )
CONNECT BY rn = PRIOR RN+1
ORDER BY LN desc )
WHERE ROWNUM=1
declare
str varchar2(32767);
begin
for i in (select sal from emp) loop
str:= str || i.sal ||',' ;
end loop;
dbms_output.put_line(str);
end;
COLUMN employees FORMAT A50
SELECT e.deptno,
get_employees(e.deptno) AS employees
FROM (SELECT DISTINCT deptno
FROM emp) e;
DEPTNO EMPLOYEES
10 CLARK,KING,MILLER
20 SMITH,JONES,SCOTT,ADAMS,FORD
30 ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES
CREATE OR REPLACE FUNCTION concatenate_list (p_cursor IN SYS_REFCURSOR)
RETURN VARCHAR2
IS
l_return VARCHAR2(32767);
l_temp VARCHAR2(32767);
BEGIN
LOOP
FETCH p_cursor
INTO l_temp;
EXIT WHEN p_cursor%NOTFOUND;
l_return := l_return || ',' || l_temp;
END LOOP;
RETURN LTRIM(l_return, ',');
END;
COLUMN employees FORMAT A50
SELECT e1.deptno,
concatenate_list(CURSOR(SELECT e2.ename FROM emp e2 WHERE e2.deptno = e1.deptno)) employees
FROM emp e1
GROUP BY e1.deptno;
DEPTNO EMPLOYEES
10 CLARK,KING,MILLER
20 SMITH,JONES,SCOTT,ADAMS,FORD
30 ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES
CREATE OR REPLACE TYPE t_string_agg AS OBJECT
g_string VARCHAR2(32767),
STATIC FUNCTION ODCIAggregateInitialize(sctx IN OUT t_string_agg)
RETURN NUMBER,
MEMBER FUNCTION ODCIAggregateIterate(self IN OUT t_string_agg,
value IN VARCHAR2 )
RETURN NUMBER,
MEMBER FUNCTION ODCIAggregateTerminate(self IN t_string_agg,
returnValue OUT VARCHAR2,
flags IN NUMBER)
RETURN NUMBER,
MEMBER FUNCTION ODCIAggregateMerge(self IN OUT t_string_agg,
ctx2 IN t_string_agg)
RETURN NUMBER
SHOW ERRORS
CREATE OR REPLACE TYPE BODY t_string_agg IS
STATIC FUNCTION ODCIAggregateInitialize(sctx IN OUT t_string_agg)
RETURN NUMBER IS
BEGIN
sctx := t_string_agg(NULL);
RETURN ODCIConst.Success;
END;
MEMBER FUNCTION ODCIAggregateIterate(self IN OUT t_string_agg,
value IN VARCHAR2 )
RETURN NUMBER IS
BEGIN
SELF.g_string := self.g_string || ',' || value;
RETURN ODCIConst.Success;
END;
MEMBER FUNCTION ODCIAggregateTerminate(self IN t_string_agg,
returnValue OUT VARCHAR2,
flags IN NUMBER)
RETURN NUMBER IS
BEGIN
returnValue := RTRIM(LTRIM(SELF.g_string, ','), ',');
RETURN ODCIConst.Success;
END;
MEMBER FUNCTION ODCIAggregateMerge(self IN OUT t_string_agg,
ctx2 IN t_string_agg)
RETURN NUMBER IS
BEGIN
SELF.g_string := SELF.g_string || ',' || ctx2.g_string;
RETURN ODCIConst.Success;
END;
END;
SHOW ERRORS
CREATE OR REPLACE FUNCTION string_agg (p_input VARCHAR2)
RETURN VARCHAR2
PARALLEL_ENABLE AGGREGATE USING t_string_agg;
/ -
How to display 7 values of single field in row wise.
hi,
how to display 7 values of single field in row wise.
thankx in advance.hi ,
do it like this :
1 Place ur UI element in tranparent container with Layout as Row Data and Layout Data as Row Head Data
2 Ur first UI , which contains the first value as Row Head Data ,
3 Others as Row Data
u can do it with Matrix Data as well
if u want to give space , u can use HORIZONTAL GUTTER and set its width to medium / large / Xlarge
also there is a UI element "INVISIBLE ELEMENT" ,
1 u can use this UI element to provide space between ur other UI elements in the view
2 u can insert a text element as well , and in the Text property of the element press ALT + 0160.
u can give the space bw UIs as desired.
regards,
amit -
How to find max based on 2 columns.
Hi I have a table where I have two numeric fields (date and time) )(thouse field are not date time format but numeric)
Column A represents date and column B represent time.
How would I find max value of column A and with results for A find Max for B.
example
A - - - - - - - - - -B
101010 - - - - - 202020
101011 - - - - - 202021
101012 - - - - - 202021
101010 - - - - - 202022
101012 - - - - - 202020
What I looking for is
A - - - - - - - - - - B
101012 - - - - - 202021
ThanksYou can try one of the following...
sql> select * from temp;
A B
101010 202020
101011 202021
101012 202021
101010 202022
101012 202020
1 select a,b from (
2 select a,
3 b,
4 rank () over (order by a desc, b desc) rnk
5 from temp
6* ) where rnk = 1
sql> /
A B
101012 202021
1 select a,b from (
2 select a,b from temp
3 order by a desc, b desc
4* ) where rownum = 1
sql> /
A B
101012 202021Please try to provide create table statements and insert data scripts instead of "select * from table".
It helps creating your case easier. -
How to find the value of a variable in other program
How to find the value of a variable in other program say I am in a FM and this FM is being called in from other program and I want to know some of the variable details of the program from the FM itself. Imagine if this is a txn. and I need to know the details from some of the programs while executing the same transaction
Regards
VinHi Vinayak,
you will be having your first program values in internal table or some variables,
when you are calling the second program you wii use like this,
SUBMIT <Second Program Name> USING SELECTION-SCREEN '1000'
WITH s_emp(second program select-options) IN t_emp(first program variables)
WITH p_chk EQ t_chk
WITH p_r1 EQ t_r1
WITH p_month EQ t_month
WITH s_cust1 IN t_cust1
WITH p_r2 EQ t_r2
WITH s_cust2 IN t_cust2
WITH s_week IN t_week
AND RETURN.
you have pas like this to get your first program details. -
How to find report values using report writer
hi,
Please help me.
How to find report values using report writer
Regards,
RRK.
Edited by: Alvaro Tejada Galindo on Feb 6, 2008 12:01 PMThanks all for the reply.
I am trying to solve a problem where report parameter value that is set at Management Console is wiped out after calling replaceConnection.
databaseController.replaceConnection(oldConnectionInfo, newConnectionInfo,
null,DBOptions._doNotVerifyDB);
We have to support changing database connection from a java utility
class. But once replaceConnection is called all existing static parameter values are lost. To fix this issue we thought of getting parameters and values before calling replaceConnection and setting it after replaceConnection.
Version is CS2008 SP3 - version 12.3.0.601
If there is any other option of fixing the original wipe out issue?
ParameterValues.getValues() didn't return value. I will try ParameterValues.getCurrentCalues() but the document says ParameterValues.getValues() is equivalent to the IParameterField.getCurrentValues() method unless it is empty, in which case it is equivalent to the IParameterField.getDefaultValues() method.
So getCurrentValues() may not work. -
How to find the Values of SAP Gateway Server Host and Gateway Service Valu
Hi All,
I installed SAPR/3 4.7 EE on Windows. For configuring SLD and LDAP i am unable to give the SAP Gateway Server Host and Gateway Service values.
Can any one plz suggest me how to find these values.
Regds
PhanikumarHello, SAP Gateway Server Host and Gateway Service are used to set up rfc connectivity, that is the host name and the system number where your sld and ldap is responding, if you have no sld and no ldap , just simply uncheck that options while installing.
Have a nice week end, Luciano. -
Hi
I have SPGridView control (fetching value from DB) with a column which is having multiple values
in single row seperated by ";", whenever filter applied it show these values in single row but i want
to dispaly these values separately in diff. rows when column filter is applied.
I have exactly same req. as mentioned in http://sadomovalex.blogspot.in/2011/03/spgridview-with-filtering-by-multiple.html
but this solution didn't work for me.
Please help/suggest.Hi Erland,
Thank you very much for the answer. Sorry I had to be more accurate on my XML : This XML is in a SQL Server Table column. This table also has an id column. It will be great if you can answer specifically to this.
<RootNode>
<Node1>
<Line_id_Node>1 </Line_id_Node>
<A>
<B>
<D>Val1 </D>
</B>
<B>
<D>Val2 </D>
</B>
<B>
<D>Val3 </D>
</B>
</A>
</Node1>
<Node1>
<Line_id_Node> 2 </Line_id_Node>
<A>
<B>
<D>Val4 </D>
</B>
<B>
<D>Val2 </D>
</B>
</A>
</Node1>
<Node1>
<Line_id_Node> 3 </Line_id_Node>
<A>
<B>
<D>Val5 </D>
</B>
</A>
</Node1>
</RootNode>
Expected O/P:
Line_id_Node Column_D
1 1
val1, val2, val3
2 2
val4, val2
3 3
val5
Nichesl -
How to find these values fall in what time?
Post Author: newcruser
CA Forum: General
From 9 AM to 5 PM time range..how to find these values fall where?.
Is that done using group selection method?. Please give me idea and direction
UserId Type login logout1 1 2008-04-13 09:30:42 2008-04-13 10:30:122 2 2008-04-13 09:30:12 2008-04-13 11:00:323 1 2008-04-13 10:30:32 2008-04-13 12:56:234 2 2008-04-13 10:30:42 2008-04-13 12:00:345 2 2008-04-13 11:30:34 2008-04-13 13:40:236 1 2008-04-13 12:30:43 2008-04-13 13:00:437 1 2008-04-13 13:20:43 2008-04-13 14:45:218 2 2008-04-13 14:30:42 2008-04-13 15:15:599 1 2008-04-13 15:00:42 2008-04-13 16:30:4210 1 2008-04-13 16:20:42 2008-04-13 17:00:00Post Author: newcruser
CA Forum: General
In my case minimum (login) time changes and maximum(logout) time changes everyday.
I want to create from minimum (login) to maximum(logout) for every hour, how many people are online. How to do?.
UserId login logout1 2008-04-13 09:30:42 2008-04-13 10:30:122 2008-04-13 09:30:12 2008-04-13 11:00:323 2008-04-13 10:30:32 2008-04-13 12:56:234 2008-04-13 10:30:42 2008-04-13 12:00:345 2008-04-13 11:30:34 2008-04-13 13:40:236 2008-04-13 12:30:43 2008-04-13 13:00:437 2008-04-13 13:20:43 2008-04-13 14:45:218 2008-04-13 14:30:42 2008-04-13 15:15:599 2008-04-13 15:00:42 2008-04-13 16:30:4210 2008-04-13 16:20:42 2008-04-13 17:00:00
i found minimum (login) and maximum(logout) using below formula. Now i want to find every hour from minimum (login) to maximum(logout) , so i can use each hour value in formula to calculate how many people are online for that particular time. How to do that?.
@Minimum
DatePart("h",(Minimum ()))
@Maximum
DatePart("h",(Maximum())) -
How do find out the number of rows
how to find out the number of rows of as all tables in a schema with one sql statement
Hi,
What u can try doing is...
declare
numrows number;
begin
for i in (select tname from tab)
loop
execute immideate 'select count(1) into numrows from ' | | i.tname ;
dbms_output.put_line(numrows);
end loop;
end;
Hope this helps. This works only in 8i. So if u need to do the same in 8.0 u have to use dbms_sql pkg.
The logic is same but the way u open ands execute the code is a bit diff.
Best Of Luck.
Regards,
Ganesh R -
How to find max(time) from table using group by
how to find max(time) from table using group by
select var max(time)
from table
into (var1, time1)
where .....
group by var.
it is fetching record which is top in table.
if u can help?
regards.No this will fetch the maximum time from teh table.
select var max(time)
from table xxxx
into (var1, time1)
where .....
group by var.
Refer this code
TABLES SBOOK.
DATA: COUNT TYPE I, SUM TYPE P DECIMALS 2, AVG TYPE F.
DATA: CONNID LIKE SBOOK-CONNID.
SELECT CONNID COUNT( * ) SUM( LUGGWEIGHT ) AVG( LUGGWEIGHT )
INTO (CONNID, COUNT, SUM, AVG)
FROM SBOOK
WHERE
CARRID = 'LH ' AND
FLDATE = '19950228'
GROUP BY CONNID.
WRITE: / CONNID, COUNT, SUM, AVG.
ENDSELECT. -
How To Concatenate Column Values from Multiple Rows into a Single Column?
How do I create a SQL query that will concatenate column values from multiple rows into a single column?
Last First Code
Lesand Danny 1
Lesand Danny 2
Lesand Danny 3
Benedi Eric 7
Benedi Eric 14
Result should look like:
Last First Codes
Lesand Danny 1,2,3
Benedi Eric 7,14
Thanks,
David JohnsonStarting with Oracle 9i
select last, first, substr(max(sys_connect_by_path(code,',')),2) codes
from
(select last, first, code, row_number() over(partition by last, first order by code) rn
from a)
connect by last = prior last and first = prior first and prior rn = rn -1
start with rn = 1
group by last, first
LAST FIRST CODES
Lesand Danny 1,2,3
Benedi Eric 7,14Regards
Dmytro
Maybe you are looking for
-
Printing in GREEN instead of B/W for OS 9 program
This is absolutely baffling to me. I have an ibook G4 that runs OS 10.4. My printer is a HP PSC 1610 all-in-one. When I try to print a Black & White document (in B/W mode) from a screenwriting program that runs in OS 9, it comes out GREEN! I even tri
-
Calendar events not showing up in widget for NC?
Hi! Well I have a question about the calendar widget. Yesterday on my today view of the notification center I saw (in my tomorrow summary) that there is an all day event scheduled for today(The Veterans Day ) and when today I opened the calendar and
-
Only first character of plugin name is shown
I'm developing a plugin using the Transmit API and for some reason it's only displaying the first character of the display name in the Playback window. The code is as follows: #define PLUGIN_DISPLAY_NAME L"My Plugin" memcpy(&outPluginInfo->outDisplay
-
Hi, Could anyone tell me if it is possible to create a stop motion film with onion skinning effects using Final Cut Pro X? Failing that, is there any effect in FCPX which I could use to show me where the last frame was positioned in a stop motion fil
-
Too bright bottom corners on the screen
Hi all, I bought my PB G4 for about 4 months and I just noticed that the right and the left corners of the screen are too bright compared to other area. Did anyone find this issue before ? If yes, how did you solve this problem ?? Thanks a lot in adv