Selecting a column base on maximum value
Hi ,
ColumnA ColumnB
A 15
B 45
C 35
D 75
E 55
I need to get Column A based on Max and Min Value of Column B
Here: I need to get the answer as D and A
I could do this using formula or running totals but these only display in either Details, Group Header/Group Footer Sections.
As these values should go between the Text in the report,I need to place these Values in either Report Header/Report Footer.
Thanks,
Hi Deep,
If my understanding is correct on your requirement, I have one suggestion.
Can you create sub reports with your working logic and place them in your main report header?
Thanks
Soma
Similar Messages
-
How to check the maximum Value and Last value in Reports CP column
Hi all
First of all i am sory that iam posting this question in forms instead of Reports....i had posted it in reports but no one reply and i need uirgent solution so I post here....
My problem is that in Report I have calculated some values in CP column......Like
:CP_Total := :Frieght * Rate ...etc
Know i want to ask that how can I get the last value that will be return the by this column????and also the maximum value that it will return
Thanks in advance
Shayan
[email protected]You mast build Summary column out of the query and select maximum to your maximum value of CP in Report level (or last for last value).
-
Dear Friends
I want to select the maximum value according to the following script
select H_TRANS_DATE,NVL(D_CURRENT_METER,0) INTO L_DATE,LOC_VAR
from (select d_current_meter,H_TRANS_DATE
FROM MAINTENANCE_HEADER
WHERE H_CAR_NO=:REC_MASTER.H_CAR_NO
AND MAINTENAMCE_STATUS = 2
order by H_TRANS_DATE desc)
where rownum = 1;
it works fine in sqlplus and it gives the correct result, but when I copy the same code to my Oracle Forms Builder it gives the following Error 103 at line 23 column 16 encountered symbol ORDER when
expecting one of the following) * &
When I remove the order by the error message goes but I am not getting the correct result ,how can I correct this script
Best Regards
JamilYes I have copied/pasted the correct code ?
and the field name in the database same as the following
AND MAINTENAMCE_STATUS = 2
any other idea , and my form version is
Forms [32 Bit] Version 6.0.8.11.3 (Production)
Oracle Toolkit Version 6.0.5.35.0 (Production)
PL/SQL Version 8.0.6.0.0 (Production)
Oracle Procedure Builder V6.0.8.11.0 Build #449 - Production
Best regards
Jamil -
Hi When i create the downpayment process in the invoice i get amount as value but my requirement is in percentage even after i select the percentage basis milestone billing please help what can be done
downpayment percentage , so if i want 50 percent of order value to be paid and when i go to faz type the invoice is created for 0 value that 50 percent of the amount is not getting calculated , where as when i enter in order same as 50 percent in amount it gets calculated in invoice, any help ?
-
How To select maximum Value in a specifieid field in internal table.
How To select maximum Value in a specifieid field in internal table?
Step : 1
Sort itab by <Field1> descending.
Just sort the internal table by the field.
STEP: 2
Then read the table at index 1.
Read table itab index 1.
ITAB-FIELD = MAX . " Max field will come in the first row of the internal table.
Regards,
Gurpreet -
How can i select other column values('-' separated) in group by function
CREATE TABLE EMP (
EMPNO NUMBER(4) NOT NULL,
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
SAL NUMBER(7)
INSERT INTO EMP(EMPNO, ENAME, JOB, SAL) VALUES (7369, 'SMITH', 'CLERK', 800);
INSERT INTO EMP(EMPNO, ENAME, JOB, SAL) VALUES (7499, 'SMITH', 'SALESMAN', 1600);
INSERT INTO EMP(EMPNO, ENAME, JOB, SAL) VALUES (7521, 'ALLEN', 'SALESMAN', 2400);
In Output I want 3 columns : EMP,SUM(SAL),JOB(hyphenSeparated)
Means i want my output like
First row : SMITH,2400,CLERK-SALESMAN
Second row : ALLEN,2400,SALESMAN
I tried to write following sql : select ename,sum(sal) from emp group by ename
But i want other colummn value in '-' separated. but group by is only allowing agreegated function.
How can i select other column value using group by function.SQL> select ename,sum(sal), listagg(job, '-') within group (order by job) as job from emp group by ename;
ENAME SUM(SAL) JOB
ALLEN 2400 SALESMAN
SMITH 2400 CLERK-SALESMANnote: LISTAGG is a feature of 11.2 -
ADF 11g- Selecting Maximum value of a field on Commit Button
Hi
I am trying to assign a value to a field on form by selecting max(id)+1 from database table on commit button.
It assign the value to field but try to commit before assigning value.
code is like this:-
public String commandButton2_action() { ////////////////a commit button.
BindingContainer bindings = getBindings();
OperationBinding operationBinding = bindings.getOperationBinding("Commit");
commandButton3_action();////////////Retrieve the maximum value from database.
Object result = operationBinding.execute();
if (!operationBinding.getErrors().isEmpty()) {
return null;
return null;
please do guide. what to do.
Regards
M NiazThanks,
I know, that's why i am try to put this on save button instead on any other.
But this is not an issue whether to use sequence or max()+1. I can use sequence instead but even then i have to get the nextvalue on form before commit.
and i have to put that on commit button.
Commit but try to commit the form before getting anything from DB.
M Niaz -
In column Chart when Y values are grater than y linear axis maximum it doesnt show the Bar
Hi Guys,
In column Chart when Y values are grater than y linear axis maximum it doesnt show the Bar.But i want show the bar upto the max limit of y linear axis without changing the max limit.
Consider following example:
Y values are 80 90 200 300
and following are the output :
Left:When i am not setting maximum property of linear axis.
Right :When i am setting maximum property of linear axis to 200.
In right 4th bar is not visible bcoz value for that bar is 300 which is excedding maxium.But i want the 4th bar to appear same as 3rd bar.
How i can do this?
Thanks in advance.Are you going to show the bar going past the maximum value?
If not, then you should change the Y value when entered into the array to the maximum value allowed. i.e.
if(itemYValue > maxAllowedValue) {
itemYValue = maxAllowedValue;
Where maxAllowedValue is a variable you set on the application to control the maximum value for the chart.
This is assuming that you are loading the values into an Array before updating the chart dataprovider with that array. -
How to fetch the maximum values of 2 columns
Hi All,
I need to fetch the maximum value of 2 columns. For example I need to fetch the latest record for which i have to fetch the latest date and time. Date and time fields are 2 different columns. As of now am doing it the crude fetching the latest date records and then fetching the latest time record.
Is there any other smarter way to do it. The one am doing rite now is turning out to be very performance intensive at the moment for me. Also I could not apply max condition for two fields together.
Please guide.
Thanks,
NagrajHi Jaspreet,
Thanks for your response. But the problem am facing with this approach is I have to do this for n number of records in another internal table which is making it to cumbersome and affecting performance.
Please suggest is there any better way to do it.
Thanks,
Nagraj -
Need to do data selection on a column basis.
Post Author: rconner
CA Forum: Data Connectivity and SQL
I need to do different data selection on a column basis instead of on the whole report. Example, I have 3 General Ledger account numbers.
5100.HOURS
5100.OT
5100.ONCALL
I need to see the units for each of these accounts per customer. My report lists each of the 3 accounts on separate rows and I need them to be side by side in order to do caluculations on the 3 fields.
Th report should look like:
Customer Name Account HOURS Units OT Units ONCALL UNITS Total
XYZ Corp. 5100 Hours 15 OT 3 ONCALL 2 20
At this time the report looks like the example below:
XYZ Corp. 5100 Hours 15
XYZ Corp. 5100 OT 3
XYZ Corp. 5100 ONCALL 2
Does anone know if this is possible and if so, how to do it?
Thanks,
RickPost Author: yangster
CA Forum: Data Connectivity and SQL
A simple way to do this would be to group on customer name\account #.create 3 formulas@hoursif account = hours then units else 0@OTif account = OT then units else 0@OnCallif account = ONCALL then units else 0put these in the details section, sum each formulaand simply put in text fields for hours, ot, and oncall next to each of the sums and you will get the desired layout you are after -
Dynamically display title based on value selected in column selector
Hi All,
Can it be possible to show the report title dynamically based on value selected in column selector . suppose i have two column status and region . When i will select status in the column selector the title of the report will show " Status Summary" when i will select region then the title will change to "Region Summary". Please help me...Hi,
create dashboard prompt with column selector functionality like following way
write the following query in your dashboard prompt sql results
select region name from subject area name
Union all
select sub_region name from subject area name
like this and put one presentation variable for this dashboard prompt like var1
in your report write formula in your column like this *case when @{var1)='region column' then 'Region Summary' else ' ' end*
and refer this column in narrative view like @1 then narrative act like a title view.
Hope this helps you
Regards
Naresh -
Selecting a column in a table according to a value
Hi,
I am stuck with a little problem here. I need to fill a column according to a value. I have an xml that will looks like this to make it simple. (Don't worry, I am not managing the status of a stock of Candy ;-))
I have to build in rtf.
<?xml version="1.0" encoding="UTF-8" ?>
- <ROWSET>
- <ROW>
<CANDY>Bubble gum</CANDY>
<SUGAR>SUGARFREE</SUGAR>
</ROW>
- <ROW>
<CANDY>Cinnamon candy</CANDY>
<SUGAR>SUGARFREE</SUGAR>
</ROW>
- <ROW>
<CANDY>Gummy candy</CANDY>
<SUGAR>SUGAR</SUGAR>
</ROW>
</ROWSET>
I have a table with two columns. I need to put on the left column the "SUGARFREE" candy and on the right the "SUGAR" candy.
Is there any condition to make this happen. Or do I have to make two table of one column next to the other and adapt a if condition in the for-each.
best regards,
OlivierHave the same table structure with two columns and have for-each with conditions in each of your columns.
Say in column1: <?for-each:ROW[SUGAR='SUGARFREE']?>text to print <?end for-each?>
column2: <?for-each:ROW[SUGAR='SUGAR']?>text to print <?end for-each?>
Hope this is what you want -
Query on column with comma separated values
I have a proposed table with unnormalized data like the following:
ID COLA COLB REFLIST
21 xxx zzz 24,25,78,412
22 xxx xxx 21
24 yyy xxx 912,22
25 zzz fff 433,555,22
.. ... ... ...There are 200 million rows. There is maximum of about 10 IDs in the REFLIST, though typically two or three. How could I efficiently query this data on the REFLIST column? e.g. something like:
SELECT id FROM mytable WHERE :myval in reflistLogically there is a many to many relationship between rows in this table. The REFLIST column contains pointers to ID values elsewhere in the table. The data could be normalized so that the relationship keys are in a separate table (in fact this is the current solution that we want to change).
ID REF
21 24
21 25
21 78
21 412
22 21
24 912
... ...The comma separated list seems instinctively like a bad idea, however there are various reasons for proposing it. The main reason is because the source for this data has it structured like the REFLIST example. It is an OLTP-like system rather than a data warehouse. The source code (and edit performance) would benefit greatly from not having to maintain the relationship table as the data changes.
Going back to querying the REFLIST column, the problem seems to be building an approriate index for the data. The ideas proposed so far are:
<li>Make a materialized view that presents the relationships as normalized (e.g. as in the example with ID, REF columns above), then index the plain column - the various methods of writing the view SQL have been widely posted.
<li>Use a Oracle Text Index (not something I have ever had call to use before).
Any other ideas? Its Oracle 10.2, though 11g could be possible.
Thanks
JimSomething like this ?
This is test demo on my 11.2.0.1 Windows XP
SQL> create table test (id number,reflist varchar2(30));
Table created.
SQL> insert into test values (21,'24,25,78,412');
1 row created.
SQL> insert into test values (22,'21');
1 row created.
SQL> insert into test values (24,'912,22');
1 row created.
SQL> insert into test values (25,'433,555,22');
1 row created.
SQL> select * from test
2 where
3 ',' || reflist || ',' like '%,22,%';
ID REFLIST
24 912,22
25 433,555,22
SQL>Source:http://stackoverflow.com/questions/7212282/is-it-possible-to-query-a-comma-separated-column-for-a-specific-value
Regards
Girish Sharma
Edited by: Girish Sharma on Jul 12, 2012 2:31 PM -
Hello Friends,
In one of our production system, WSH_NEW_DELIVERIES_S Reaching maximum value.Current application version is #11.5.10.2 and Database version is 11.2.0.3.0
Can any one help what we can do, do we have any Meta link Note ID's or Patches to do it. as customer will not agree to ALTER the maxvalue with Out Oracle NOTEID or Approved Patch.
As of now Maximum value defined in sequence is 285700000 and the WSH_NEW_DELIVERIES_S.currval is 285012483.
Please suggest.
Current Script in System is as below:
CREATE SEQUENCE WSH.WSH_NEW_DELIVERIES_S
START WITH 285012482
MAXVALUE 285700000
MINVALUE 1
NOCYCLE
NOCACHE
ORDER;An another possibility is to do the opposite to what I just wrote. Upload the true definition to the database an compare with the one you are not sure about via SQL:
1. Backup the WFT file where the standard/seeded workflow is provided
2. Edit it and change the name of the ITEM_TYPE. For instance, change it from OEOL to OEOL_TMP (cannot exceed 8 characters)
3. Upload it to the database with WFLOAD
4. Compare the design tables for the two if them (WF_ITEM_TYPES, WF_ACTIVITIES, WF_MESSAGES, WF_PROCESS_ACTIVITIES, WF_ITEM_ATTRIBUTES, etc). If the table provides a VERSION column then the query would need to use a WHERE END_DATE is null (so that you get only the active/current version of the object). A select... MINUM select would do the job.
I would do this in test though, to avoid a mistake can cause any issues.
Regards,
Alejandro
Edited by: Alejandro Sosa on Feb 4, 2013 7:07 AM -
Select LONG column into CLOB variable
Hi all,
I am trying retrieve the data present in a LONG column into a CLOB variable.
However I am getting an error, pls let me know how I can resolve it.
DECLARE
v_text CLOB;
BEGIN
SELECT TO_LOB(trigger_body)
INTO v_text
FROM
user_triggers
WHERE
ROWNUM <= 1;
END;
ERROR at line 8:
ORA-06550: line 8, column 20:
PL/SQL: ORA-00932: inconsistent datatypes: expected NUMBER got LONG
ORA-06550: line 8, column 5:
PL/SQL: SQL Statement ignored
Let me know if there is an alternate to this. I would like to get the data present in the LONG column into a variable.
The reason why I am not retrieving the LONG column into LONG variable is stated below (from Oracle Website):
You can insert any LONG value into a LONG database column because the maximum width of a LONG column is 2**31 bytes.
However, you cannot retrieve a value longer than 32760 bytes from a LONG column into a LONG variable.
Thanks and Regards,
SomuThere are couple of things I did (listed in order):
1) Create Global Temporary Table containing a CLOB column
2) Select LONG column and convert to CLOB by using TO_LOB and insert into Global Temporary Table containing a CLOB column
2) Select from this Global Temporary Table (which already contains data in CLOB) and assign it to a CLOB variable.
This is done because you can not directly use TO_LOB in a select statement to assign the value to a CLOB variable.
Stated below is an example:
-- Create Temporary Table
CREATE GLOBAL TEMPORARY TABLE glb_tmp_table_lob(
time TIMESTAMP WITH LOCAL TIME ZONE,
text CLOB
ON COMMIT DELETE ROWS;
-- PL/SQL Block to Execute
DECLARE
v_clob CLOB;
BEGIN
-- Insert into Temporary Table by converting LONG into CLOB
INSERT INTO glb_tmp_table_lob (
time ,
text
SELECT
sysdate ,
TO_LOB(dv.text)
FROM
dba_views dv
WHERE
ROWNUM <= 1
-- Select from the Temporary table into the variable
SELECT
gt.text
INTO
v_clob
FROM
glb_tmp_table_lob gt;
COMMIT;
-- Now you can use the CLOB variable as per your needs.
END;
/
Maybe you are looking for
-
My ipod is displaying a usb cable at the top of it is itunes,i get a message on my computer saying the usb is not reconized.my ipod will not go back to the original when i unplug it from the computer, help
-
Hi all, reports version : 6i I am trying to run a receipt based report , passing a range of receipt number in parameter form i need to get the report of the given range of receipt number I give the first receipt number('RV00001/2008') in the list in
-
Applications Folder In Home Folder?
On both of the Macs I use, my iMac and MBP, there is an applications folder with in my home folder. It is completely empty and has a size of Zero KB. It has the same Applications folder icon you see with the one located in "Macintosh HD". Is this a n
-
[Solved] X + Ati = BlackScreen
I've been trying to set up my X server on a new install of Arch. I have an ATI X850XT graphics card and am trying to use the open source ATI driver however I've been having the same problem from ATI's own driver. When I run startx I get a completely
-
After I create a working ApTab-PIN it is not there when I re-open Firefox.
I bookmarked several sites, then created an aptab PIN in the ap tab bar that worked when I opened it. After I closed Firefox and reopened it, the aptab PIN was no longer there. Using Mac OSX, 10.6.7.