Using lookup function but to show multiple returns?
Okay so I have been talked through how to use a lookup function to show which student in my class has scored the highest grade. The formula used displays there name in one column and the score they achieved in another column which I have set up in a small seperate table. However as suggested in my intial lookup function search it was suggested that I would encounter a problem if two students both achieved the same highest score. However in the results table I have created it only shows one student. Is it possible to have a function or formula that will simply show the top scores and the students that scored it when they are tied?
Thanks
Marcus
The easiest way to accomplish this, Marcus, is by simply sorting all rows by grade. Sure, you can click on the column tab and hit "sort ascending", but I'm guessing you want something a little more dynamic than that.
So I've set up a class of 20 students and gave them all random grades btwn 40 - 99. (That's how it was done when I was in high school. ) I added a third column which takes that grade, multiplies it by 1000, and adds the row number of the student. This creates a unique identifier based on a possibly-non-unique grade:
Now it's simply a matter of using the LARGE function to rank these new identifiers, and then using LOOKUP to get the actual grade and name for that identifier. (Note that the grades changed; changing the focus from one cell to another creates new random values for the grades.)
The formula for columns b and c for this Ranking table are standard Lookup functions:
=LOOKUP($A1,Grades :: $C,Grades :: $B) to get the grades ($A2 for 2nd column, etc.), and
=LOOKUP($A1,Grades :: $C,Grades :: $A) to get the names.
I'd suggest hiding these identifier columns.
Now, to limit this display to the "X" highest grades, I'm going to continue this into another reply.
Vince
Similar Messages
-
Can I use a usb external hard drive larger than 2TB? I have tried to use a 3TB but it shows up as 800GB. Even tred to reformat in disk utility but only shows as 800 gb as well. It is a Seagate 3TB harddrive and enclosure. Nothing on the Seagate site about it other than it says Mac os through 10.6 is supported for larger than 2TB (might be old).
You might have better luck in the Snow Leopard community. I'll ask the hosts to relocate your post.
10.6 Snow Leopard -
I am using Iphone 5s my battery is draining like anything. Without using any application also it seems i am using iphone 5s but in show only really i am using like previous nokia 1100 model.
Are there apps on your phone right now?
I think one of your apps is causing this.
The only way to find out is to delete them all and then add them one by one to see what app maybe causing this.
Especially if you've gone thru 3 iphones already.
When you restored as new - did you sync back your stuff - apps/music or did you restore from backup? -
USING LOOKUP FUNCTION IN CHART
Good Afternoon,
I have created a simple chart in SSRS that is sourced from Analysis Services. The Grouping is by Month and the values are just attendances per month.
I want to add a 2nd series to this chart using a stored procedure in SQL.
Both share the field Month and could be linked on that field.
Does anybody know how I can use the lookup function to add this field to my chart.
Thank youYou can lookup by month. In the chart values, add a new series by clicking the Plus icon and choosing Expression. You expression should look something like:
=Lookup( Fields!AS_Month.Value, Fields!SP_Month.Value, Fields!SP_Value.Value, "SP_Dataset" )
The abbreviation AS refers to your analysis services dataset, while the SP refers to your dataset using the stored procedure. The expression matches each month used in the chart (the category group) with the month in the other data set, and retrieves the
SP_Value field to show on the chart.
If the month numbers/names match exactly, then it will work fine.
Regards,
Andrew Borg Cardona -
Aggregate using Lookup function
Is there any way to get a sum or average of data from a dataset using a Lookup function?
I have daily currency data, and want to use a lookup function to get monthly averages - at this stage, the lookup function will only return the data for the first entry of the month.
ThanksHi MIDASuer,
Per my understanding that you want to get the sum or monthly average value based on the daily currency data, right?
I have tested on my local environment and I assumed that you have an date/time type field in the table, if so, we can get the month value based on the daily date and then create row group based on the month, finally we can use the avg or sum function
to get the monthly average values.
Detail information below for your reference:
We can modify the query in the dataset to get the month value from the date:
SELECT Amount, Date, DATEPART(month, Date) AS Month
FROM TableName
Add an row gorup of the month(Month)
Use expression below to get the average value of the month and the sum of the month:
Monthly Average: =Avg(Fields!Amount.Value,"Month")
Monthly Sum : =Sum(Fields!Amount.Value,"Month")
If the amount value comes from another dataset using the lookup function, you can use expression below o get the monthly average:
=Avg(Lookup(source_expression, destination_expression, result_expression, dataset),Month")
preview like below:
More details information about the LookUp function for your reference:
https://technet.microsoft.com/en-us/library/ee210531(v=sql.110).aspx
If your problem still exists, please try to provide us some sample data and more detail information about your requirements.
Regards,
Vicky Liu
Vicky Liu
TechNet Community Support -
Using a hierarchy but also showing work orders that are not in hierarchy
good morning bi people,
i have a requirement to show data from a hierarchy which includes Operation and Maintenance information. for example it has an account broken into labour/material/trucking and below this is the pm acivity type and secondary cost element (concatenated). this hierarchy is a manually created hierarchy that is uploaded to BW and is not in ECC. The users do not want to see the concatenated field at the end of the hierarchy, but instead, want to see the Work Orders that have the PM activity types.
At the present time, we have the report using the hierarchy but we need the work orders to replace the pm activity type/secondary cost element concatenated field. the work order field is a free characteristic and when we drag in the work order in analyzer, it works correctly.
1) is this possible to use the hierarchy and somehow map the work order field to the end of the hierarchy within crystal?
2) do you have a suggestion to change the hierarchy, without being a manual nightmare?
all conversations are welcome.
ErikGood Day Ingo,
i have created a word document with screen shots of the hierarchy from BW, a screen shot of the BEx showing the free characteristic of Maintenance Order and a screen shot of the crystal report with the PM Activity type concatenated to the Cost Element. Once again, we do not wish to see the concatenated field, but rather see the Maintenance orders that have a PM Activity type the same as the concatenated field.
here is the link.
https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=0B1j5hXTptfntYWI1MDUzNGEtY2MxNy00YmMzLWJjZjEtZDA4OGZiYmMyNzFh&hl=en&authkey=CKq4xcgJ
thanks Ingo,
Erik -
Bug? using MAX() function on char(1) column returns something larger
details:
-- we have a complex nested query, where we are essentially returning the max() value into a variable
-- the max() function is being used on a char(1) column
-- where MAX() is part of an inner select, we have started getting
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
errors.
SELECT MAX(X) INTO var FROM ... works in 9i and 10g
SELECT X INTO var FROM (SELECT MAX(X) X FROM ... worked in 9i, does not work in 10g!
-- We never had problems with the code until upgrading to 10g release 2.
-- the Solution is to cast the final value with TO_CHAR(). The cast MUST be done at the outer most point of the select:
SELECT TO_CHAR(X) INTO var FROM (SELECT MAX(X) X FROM ... works
SELECT X INTO var FROM (SELECT TO_CHAR(MAX(X)) X FROM ... causes an error!
The following script demonstrates the issue, and includes the solution:
* October 3, 2006
* Possible SQL bug introduced with Oracle 10G
* Natalie Gray DBA/Developer, Environment Canada
* Description:
* Have discovered a problem with using the MAX() function
* on columns of type char(1)
* only an issue when used in an inner select
* solution (see test 4)
CREATE TABLE SQL_BUG_TEST
X NUMBER,
Y NUMBER,
Z CHAR(1)
INSERT INTO SQL_BUG_TEST (X, Y, Z)
VALUES (1,1,'A');
INSERT INTO SQL_BUG_TEST (X, Y, Z)
VALUES (1,1,'B');
INSERT INTO SQL_BUG_TEST (X, Y, Z)
VALUES (1,2,'C');
INSERT INTO SQL_BUG_TEST (X, Y, Z)
VALUES (1,2,'D');
DECLARE
TYPE REC IS RECORD (
x SQL_BUG_TEST.X%TYPE,
y SQL_BUG_TEST.Y%TYPE,
z SQL_BUG_TEST.Z%TYPE
v_rec REC;
BEGIN
-- DISPLAY THE TABLE DATA
BEGIN
DBMS_OUTPUT.PUT_LINE('TABLE DATA:');
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('SELECT * FROM SQL_BUG_TEST ORDER BY X,Y,Z;');
FOR crs IN (SELECT *
FROM SQL_BUG_TEST
ORDER BY X,Y,Z) LOOP
DBMS_OUTPUT.PUT_LINE(':'||crs.X||':'||crs.Y||':'||crs.Z);
END LOOP;
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
-- TEST 1
-- returning result from MAX into a variable when the MAX is in the outer most select
-- does not cause an error
BEGIN
DBMS_OUTPUT.PUT_LINE('*****************************************************');
DBMS_OUTPUT.PUT_LINE('TEST 1');
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('SELECT X, Y, MAX(Z) Z');
DBMS_OUTPUT.PUT_LINE('FROM SQL_BUG_TEST');
DBMS_OUTPUT.PUT_LINE('GROUP BY X,Y');
FOR crs IN (SELECT X, Y, MAX(Z) Z
FROM SQL_BUG_TEST
GROUP BY X, Y
ORDER BY X,Y,Z) LOOP
DBMS_OUTPUT.PUT_LINE(':'||crs.X||':'||crs.Y||':'||crs.Z);
END LOOP;
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
-- TEST 2
-- returning MAX() from an inner select to an outer select and then into a variable
-- causes an error
BEGIN
DBMS_OUTPUT.PUT_LINE('*****************************************************');
DBMS_OUTPUT.PUT_LINE('TEST 2');
DBMS_OUTPUT.PUT_LINE('THIS DID NOT CAUSE AN ERROR WITH ORACLE 9i');
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('SELECT * INTO v_rec');
DBMS_OUTPUT.PUT_LINE('FROM');
DBMS_OUTPUT.PUT_LINE('(SELECT X, Y, MAX(Z) Z');
DBMS_OUTPUT.PUT_LINE('FROM SQL_BUG_TEST');
DBMS_OUTPUT.PUT_LINE('GROUP BY X,Y)');
DBMS_OUTPUT.PUT_LINE('WHERE Y = 1');
SELECT * INTO v_rec
FROM
(SELECT X, Y, MAX(Z) Z
FROM SQL_BUG_TEST
GROUP BY X, Y)
WHERE Y = 1;
DBMS_OUTPUT.PUT_LINE(':'||v_rec.X||':'||v_rec.Y||':'||v_rec.Z);
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
-- TEST 3
-- casting the result from MAX to char before returning to the outer select
-- still causes an error
BEGIN
DBMS_OUTPUT.PUT_LINE('*****************************************************');
DBMS_OUTPUT.PUT_LINE('TEST 3');
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('SELECT * INTO v_rec');
DBMS_OUTPUT.PUT_LINE('FROM');
DBMS_OUTPUT.PUT_LINE('(SELECT X, Y, to_char(MAX(Z)) Z');
DBMS_OUTPUT.PUT_LINE('FROM SQL_BUG_TEST');
DBMS_OUTPUT.PUT_LINE('GROUP BY X,Y)');
DBMS_OUTPUT.PUT_LINE('WHERE Y = 1');
SELECT * INTO v_rec
FROM
(SELECT X, Y, to_char(MAX(Z)) Z
FROM SQL_BUG_TEST
GROUP BY X, Y)
WHERE Y = 1;
DBMS_OUTPUT.PUT_LINE(':'||v_rec.X||':'||v_rec.Y||':'||v_rec.Z);
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
-- TEST 4 - SOLUTION
-- the return value of MAX must be cast with to_char at the point where it is assigned to
-- variable (outer most select)
BEGIN
DBMS_OUTPUT.PUT_LINE('*****************************************************');
DBMS_OUTPUT.PUT_LINE('TEST 4 SOLUTION');
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('SELECT X, Y, TO_CHAR(Z) Z INTO v_rec');
DBMS_OUTPUT.PUT_LINE('FROM');
DBMS_OUTPUT.PUT_LINE('(SELECT X, Y, MAX(Z) Z');
DBMS_OUTPUT.PUT_LINE('FROM SQL_BUG_TEST');
DBMS_OUTPUT.PUT_LINE('GROUP BY X,Y)');
DBMS_OUTPUT.PUT_LINE('WHERE Y = 1');
SELECT X, Y, TO_CHAR(Z) Z INTO v_rec
FROM
(SELECT X, Y, MAX(Z) Z
FROM SQL_BUG_TEST
GROUP BY X, Y)
WHERE Y = 1;
DBMS_OUTPUT.PUT_LINE(':'||v_rec.X||':'||v_rec.Y||':'||v_rec.Z);
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
END;I certainly looks like a bug, but you should raise an iTAR on Metalink since Oracle does not monitor this forum.
I was able to replicate your results on my 10.2.0.1 database.
There is an easier workaround than yours. Try
ALTER TABLE sql_bug_test MODIFY (z VARCHAR2(1));That seems to eliminate the problem on my instance.
John -
DBMS_JOB using Packaged Functions but Package goes invalid
Is there any way to check a package while running a PL/SQL procedure to see if it's state is valid and then catch the exception?
In my case usually just calling any function in the package 1x clears it up but the procedure in question runs as a DBMS_JOB it just keeps failing. This procedure could run often enough that Oracle will mark it as broken but I want to give it every shot at execution on time instead of having to make it wait till the next cycle.
What I would like to do is to catch the exception for the package state being invalid and basically have it go back to the beginning of the procedure and give it another try before failing in case it is just a failure because the package has been altered.
Is there any way to do this?Firstly, I'll copy/paste my standard response regarding package state going invalid as it usually helps to have an understanding of these things...
Packages tend to fail because of their "package state". A package has a "state" when it contains package level variables/constants etc. and the package is called. Upon first calling the package, the "state" is created in memory to hold the values of those variables etc. If an object that the package depends upon e.g. a table is altered in some way e.g. dropped and recreated, then because of the database dependencies, the package takes on an INVALID status. When you next make a call to the package, Oracle looks at the status and sees that it is invalid, then determines that the package has a "state". Because something has altered that the package depended upon, the state is taken as being out of date and is discarded, thus causing the "Package state has been discarded" error message.
If a package does not have package level variables etc. i.e. the "state" then, taking the same example above, the package takes on an INVALID status, but when you next make a call to the package, Oracle sees it as Invalid, but knows that there is no "state" attached to it, and so is able to recompile the package automatically and then carry on execution without causing any error messages. The only exception here is if the thing that the package was dependant on has changes in such a way that the package cannot compile, in which case you'll get an Invalid package type of error.
And if you want to know how to prevent discarded package states....
Move all constants and variables into a stand-alone package spec and reference those from your initial package. Thus when the status of your original package is invlidated for whatever reason, it has no package state and can be recompiled automatically, however the package containing the vars/const will not become invalidated as it has no dependencies, so the state that is in memory for that package will remain and can continue to be used.
As for having package level cursors, you'll need to make these local to the procedures/functions using them as you won't be able to reference cursors across packages like that (not sure about using REF CURSORS though.... there's one for me to investigate!)
This first example shows the package state being invalided by the addition of a new column on the table, and causing it to give a "Package state discarded" error...
SQL> set serveroutput on
SQL>
SQL> create table dependonme (x number)
2 /
Table created.
SQL>
SQL> insert into dependonme values (5)
2 /
1 row created.
SQL>
SQL> create or replace package mypkg is
2 procedure myproc;
3 end mypkg;
4 /
Package created.
SQL>
SQL> create or replace package body mypkg is
2 v_statevar number := 5; -- this means my package has a state
3
4 procedure myproc is
5 myval number;
6 begin
7 select x
8 into myval
9 from dependonme;
10
11 myval := myval * v_statevar;
12 DBMS_OUTPUT.PUT_LINE('My Result is: '||myval);
13 end;
14 end mypkg;
15 /
Package body created.
SQL>
SQL> exec mypkg.myproc
My Result is: 25
PL/SQL procedure successfully completed.
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
2 /
OBJECT_NAME
OBJECT_TYPE STATUS
MYPKG
PACKAGE VALID
MYPKG
PACKAGE BODY VALID
SQL>
SQL>
SQL> alter table dependonme add (y number)
2 /
Table altered.
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
2 /
OBJECT_NAME
OBJECT_TYPE STATUS
MYPKG
PACKAGE VALID
MYPKG
PACKAGE BODY INVALID
SQL>
SQL> exec mypkg.myproc
BEGIN mypkg.myproc; END;
ERROR at line 1:
ORA-04068: existing state of packages has been discarded
ORA-04061: existing state of package body "SCOTT.MYPKG" has been invalidated
ORA-06508: PL/SQL: could not find program unit being called: "SCOTT.MYPKG"
ORA-06512: at line 1
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
2 /
OBJECT_NAME
OBJECT_TYPE STATUS
MYPKG
PACKAGE VALID
MYPKG
PACKAGE BODY INVALID
SQL>
SQL> exec mypkg.myproc
PL/SQL procedure successfully completed.
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
2 /
OBJECT_NAME
OBJECT_TYPE STATUS
MYPKG
PACKAGE VALID
MYPKG
PACKAGE BODY VALIDAnd this next example shows how having the package variables in their own package spec, allows the package to automatically recompile when it is called even though it became invalidated by the action of adding a column to the table.
SQL> drop table dependonme
2 /
Table dropped.
SQL>
SQL> drop package mypkg
2 /
Package dropped.
SQL>
SQL> set serveroutput on
SQL>
SQL> create table dependonme (x number)
2 /
Table created.
SQL>
SQL> insert into dependonme values (5)
2 /
1 row created.
SQL>
SQL> create or replace package mypkg is
2 procedure myproc;
3 end mypkg;
4 /
Package created.
SQL>
SQL> create or replace package mypkg_state is
2 v_statevar number := 5; -- package state in seperate package spec
3 end mypkg_state;
4 /
Package created.
SQL>
SQL> create or replace package body mypkg is
2 -- this package has no state area
3
4 procedure myproc is
5 myval number;
6 begin
7 select x
8 into myval
9 from dependonme;
10
11 myval := myval * mypkg_state.v_statevar; -- note: references the mypkg_state package
12 DBMS_OUTPUT.PUT_LINE('My Result is: '||myval);
13 end;
14 end mypkg;
15 /
Package body created.
SQL>
SQL> exec mypkg.myproc
My Result is: 25
PL/SQL procedure successfully completed.
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
2 /
OBJECT_NAME
OBJECT_TYPE STATUS
MYPKG
PACKAGE VALID
MYPKG
PACKAGE BODY VALID
SQL>
SQL> alter table dependonme add (y number)
2 /
Table altered.
SQL>
SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
2 /
OBJECT_NAME
OBJECT_TYPE STATUS
MYPKG
PACKAGE VALID
MYPKG
PACKAGE BODY INVALID
SQL>
SQL> exec mypkg.myproc
My Result is: 25
PL/SQL procedure successfully completed.---------------------------------------------------------------------------------------------
Secondly, from this above standard response, you can see how to check for package state if you want to determine it programatically.
;) -
Using Narrative View how to show multiple rows as one row
My answer result set Returns 3 rows
Year Rev
2005 $100
2006 $200
2007 $300
I want to display in a single line like
2005 $100 2006 $200 $2007 300
How do I achieve the above?obieefan,
Add narrative view to compund layout and in the narrative area add @1@2...
@1 refers to year column
@2 refers to dollar amount column.
mark posts promptly
J
-bifacts
http://www.obinotes.com
Edited by: bifacts on Nov 12, 2010 9:26 PM -
Using Previous function in summary rows?
Hi,
I have a requirment, where I have to use the value got in previous column in the summary row.
The scenario is as follows.
There are Product, Quantity on Hand , Order Type and Date column. I am using cross tab, As I have to use the details of columns for each date.
So date will be spreaded across table as there are more dates.
In summary column, I would like to do a calcuation for each date. And I should use the calculated amount on one date in the next date and the calcuation continues.
I am trying to use previous function, but its showing computation error.
I am attaching a excel sheet with a sample example for easy understanding.
The calculation which I used in summary row is avialble in formula section, when we select the column.
Thanks in Advance.
Regards
GowthamHi BOCP,
Yes, I am trying to use this function in Summary after Break.
Sorry, I missed out attachment. And I didn't find a way to attach it.
Suresh,
I didn't find last() function in WebI Editor. I am using BO XI R2.
Thanks a lot.
Regards,
Gowtham Sen. -
Returning Collection using table function
Hi,
I'm trying to return a collection with record type using table function but facing some issues.
Could someone help me with it.
SUNNY@11gR1> create or replace package test_pack as
2 type rec_typ is record (
3 empname varchar2(30),
4 empage number(2),
5 empsal number(10));
6 type nest_typ is table of rec_typ;
7 function list_emp return nest_typ;
8 end;
9 /
Package created.
Elapsed: 00:00:00.01
SUNNY@11gR1> create or replace package body test_pack is
2 function list_emp return nest_typ is
3 nest_var nest_typ := nest_typ();
4 begin
5 nest_var.extend;
6 nest_var(nest_var.last).empname := 'KING';
7 nest_var(nest_var.last).empage := 25;
8 nest_var(nest_var.last).empsal := 2500;
9 nest_var.extend;
10 nest_var(nest_var.last).empname := 'SCOTT';
11 nest_var(nest_var.last).empage := 22;
12 nest_var(nest_var.last).empsal := 3500;
13 nest_var.extend;
14 nest_var(nest_var.last).empname := 'BLAKE';
15 nest_var(nest_var.last).empage := 1;
16 return nest_var;
17 end;
18 end;
19 /
Package body created.
Elapsed: 00:00:00.01
SUNNY@11gR1> select * from table(test_pack.list_emp);
select * from table(test_pack.list_emp)
ERROR at line 1:
ORA-00902: invalid datatype
Elapsed: 00:00:00.01
SUNNY@11gR1>Regards,
SunnyBut if I use pipelined function instead then I'm able to retrieve the records
SUNNY@11gR1> create or replace package test_pack as
2 type rec_typ is record (
3 empname varchar2(30),
4 empage number(2),
5 empsal number(10));
6 type nest_typ is table of rec_typ;
7 function list_emp return nest_typ pipelined;
8 end;
9 /
Package created.
SUNNY@11gR1> ed
Wrote file afiedt.buf
1 create or replace package body test_pack as
2 function list_emp return nest_typ pipelined is
3 rec_var rec_typ;
4 begin
5 rec_var.empname := 'KING';
6 rec_var.empage := 24;
7 rec_var.empsal := 10000;
8 pipe row(rec_var);
9 rec_var.empname:='SCOTT';
10 rec_var.empage:=22;
11 rec_var.empsal:=2000;
12 pipe row(rec_var);
13 rec_var.empname:='BLAKE';
14 rec_var.empage:='1';
15 pipe row(rec_var);
16 return;
17 end;
18* end;
SUNNY@11gR1> /
Package body created.
Elapsed: 00:00:00.01
SUNNY@11gR1> select * from table(test_pack.list_emp);
EMPNAME EMPAGE EMPSAL
KING 24 10000
SCOTT 22 2000
BLAKE 1 2000
Elapsed: 00:00:00.00Why is that?
Regards,
Sunny -
I want single update query without use the function.
I want to update sells_table selling_code field with max date product_code from product table.
In product table there is multiple product_code date wise.
I have been done it with below quey with the use of function but can we do it in only one update query
without use the function.
UPDATE sells_table
SET selling_code = MAXDATEPRODUCT(ctd_vpk_product_code)
WHERE NVL(update_product_flag,0) = 0 ;
CREATE OR REPLACE FUNCTION HVL.maxdateproduct (p_product IN VARCHAR2) RETURN NUMBER
IS
max_date_product VARCHAR2 (100);
BEGIN
BEGIN
SELECT NVL (TRIM (product_code), 0)
INTO max_date_product
FROM (SELECT product_code, xref_end_dt
FROM product
WHERE TO_NUMBER (p_product) = pr.item_id
ORDER BY xref_end_dt DESC)
WHERE ROWNUM = 1; -- It will return only one row - max date product code
EXCEPTION
WHEN OTHERS
THEN
RETURN 0;
END;
RETURN max_date_product;
END maxdateproduct;
Thanks in Advance.Hi,
Something like this.
update setlls_table st
set selling_code =(select nvl(trim(product_code)) from
(select product_code
, rank() over (partition by item_id order by xref_end_dt DESC) rn
from product
) pr
where rn =1
and pr.item_id = st.ctd_vpk_product_code
) where NVL(update_product_flag,0) = 0 ;As such not tested due to lack of input sample.
Regards
Anurag Tibrewal. -
Lookup function issue or specific cell data binding problem
I have a dataset which has datatable having 2 columns i.e
Table( Id string,Value string)
Every single record in the datatable represents an answer to particular question, Id column being question identifier and Value column being an answer and every question has answer being stored for 7 days.
Now i have designed a report which is in the form of grid like
Day1 Answer, Day2 Answer, Day3 Answer............................Day7 Answer
Question 1
Question 2
.Question 40
I tried using lookup function in ssrs reporting service to bind every single cell in the report using data from dataset like
= Lookup("question_identifier",QuestionId.Value,AnswerValue.Value,"mydataset");
The report is working absolutely fine in the report designer as expected but when i take it to the ASP.NET website where i have to generate it, it never shows up and i get report couldn't be found and make sure you have published the report kind of errors.
I figured that this is the problem with lookup function because as soon as i removed all lookup function expressions in the report , the report started to show up but without data.
Please let me know if there is another way to go around this problem or fix this issue.
Thanks,
BR,Hi Jolly,
I don't think we need lookup function for this. We have only one dataset, the report can be easily created by simply modifying the query of the dataset and place those fields in the tablix report. Refer below example,
create table reporttable(id int, value varchar(200))
insert into reporttable values(1,'abc')
insert into reporttable values(1,'abc1')
insert into reporttable values(1,'abc2')
insert into reporttable values(1,'abc3')
insert into reporttable values(1,'abc4')
insert into reporttable values(2,'abc')
insert into reporttable values(2,'abc1')
insert into reporttable values(2,'abc2')
insert into reporttable values(2,'abc3')
insert into reporttable values(2,'abc4')
insert into reporttable values(3,'abc')
insert into reporttable values(3,'abc1')
insert into reporttable values(3,'abc2')
insert into reporttable values(3,'abc3')
insert into reporttable values(3,'abc4')
select id as [Question],'Day ' + cast(row_number() over (partition by id order by id) as varchar) + ' Answer' as AnsCol
from reporttable
Regards, RSingh -
Post Author: jeff.p18
CA Forum: Data Integration
Hello (mother-tongue = french)
I'm a BODI beginner and I often have things lije this to code :
SELECT gd.num_ecrou_ini, ae.dat_epreuve, ae.cod_diplome, u2018Ru2019, 2
FROM gdet_det gd,
atf_expertise ae,
t_ods_w_diplome wde
WHERE gd.num_ecro_cou = ae.num_ecro_cou
AND gd.num_ecro_cou = ( SELECT max(gd2.num_ecro_cou)
FROM gdet_det gd2
WHERE gd2.num_ecro_ini = gd. num_ecro_ini )
AND gd.num_ecrou_ini not in ( SELECT wde2.num_ecrou_ini
FROM t_ods_w_diplome wde2 )
AND 2 < = ( SELECT min(hd2.priorite)
FROM t_ods_h_diplome hd2
WHERE hd2.num_ecrou_init = gd.num_ecrou_ini)
AND gd.num_ecro_cou = ( SELECT max(ae2.dat_expertise)
FROM gdet_det ae2
WHERE ae2.num_ecro_cou = ae. num_ecro_cou )
I wonder if it is recommended to use lookup to implement it in BODI.
Look at my where clause in BODI :
GDET_DET_1.NUM_ECRO_COU = ATF_EXPERTISE_1.NUM_ECRO_COU ANDlookup_ext([ds_ods_info_penit.SCOTT.T_ODS_W_DIPLOME,'PRE_LOAD_CACHE','MAX'], [NUM_ECRO_INI],[0],[NUM_ECRO_INI,'=',GDET_DET_1.NUM_ECRO_INI]) = 0 ANDlookup_ext([ds_ods_info_penit.SCOTT.T_ODS_H_DIPLOME,'PRE_LOAD_CACHE','MIN'], [PRIORITE],[9],[NUM_ECROU_INIT,'=',GDET_DET_1.NUM_ECRO_INI]) >= 2 ANDlookup_ext([ds_source_gide_source.dbo.GDET_DET,'PRE_LOAD_CACHE','MAX'], [NUM_ECRO_COU],[NULL],[NUM_ECRO_INI,'=',GDET_DET_1.NUM_ECRO_INI]) = GDET_DET_1.NUM_ECRO_COU ANDlookup_ext([ds_source_gide_source.dbo.ATF_EXPERTISE,'PRE_LOAD_CACHE','MAX'], [DAT_EXPERTISE],[NULL],[NUM_ECRO_COU,'=',GDET_DET_1.NUM_ECRO_COU]) = ATF_EXPERTISE_1.DAT_EXPERTISE
It is working but should i choose another way to do that ?
subsidiary question : does BODI use Oracle analytical function to perform that ?
Thanks in advance
+Hi jimmy5495,
According to your description, it seems like you don’t know how to correctly use Lookup function. Based on my research, Lookup function is not supported to be used in a single textbox that means outside Data Grid with multiple datasets environment. Because
in a single textbox with multiple datasets environment, it only supports Aggregate functions when we want to use fields in it. While Aggregate functions are not allowed inside the Destination or Result expressions of a Lookup function.
We can add the expression in a table textbox in the design surface, then delete the other cells. While if we want to add this expression in page header, since page header can only contain static items, I think we could achieve this goal in current release
of Reporting Services.
References:
Aggregate Functions Reference (Report Builder and SSRS)
Page Headers and Footers (Report Builder and SSRS)
Regards,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
I've created over 50 tutorials in Adobe Presenter/PowerPoint.
Now I'm trying to use a PowerPoint feature called Show and
Return, and I can't seem to get it to work in Adobe Presenter.
Could someone please provide some advice on how to do this?
Let's say I have a training module which tells you how to
print fliers. There may be 10 different spots within a tutorial
that give you a link to learn how to print fliers. So let's say
you're viewing slide 5, there's a link that says "Learn how to
print fliers." You click the link, it takes you to a Custom Show,
which shows you 5 slides on how to print a flier, and then it
returns you to slide 6 when it's done.
Now on slide 30, there's a link that says "Learn how to print
fliers." You click that link, and it takes you to the SAME Custom
Show, shows you the same 5 slides, and then returns you to slide 31
(the slide following the slide you clicked the link from).
This function works fine when I'm just using PowerPoint, but
I can't seem to make it work in Presenter. Once I publish the file
and use the function, it does not Return when it is done.
How do I make it so that Show and Return works with Presenter
presentations?I'm still looking for a method to reuse content within a
single presentation.
Does anyone who creates presentations have a desire to re-use
slides within the presentation? There's a great feature in Power
Point for this called Show and Return, but I can't seem to get it
to work in Presenter.
Anyone else had luck with this?
Maybe you are looking for
-
Free/Busy Info Unavailable in OWA & Outlook
When we try to add ONLY "User A" to meeting request using Outlook client/OWA, no free busy information could be retrieved. Other user try to add "User A" to meeting request also receive the same message. However, when "User A" from her Outlook, she c
-
Lightroom4 Mac OS 10.9(Mavericks)でスライドバーのカラー表示が消えた
お世話になります. Macbook Pro 2011 Late 13inchでLightroom4(Ver. 4.4)を使用しています. OS 10.9(Mavericks)にアップデートしたところ.Lightroom4の現像モジュールにおいて 露光量.WB.色被り補正.個別カラー等のスライドバーのところで. カラー表示が出なくなってしまいました. キャプチャした画像を貼っておきます. キャプチャ画像右側のスライドバーのカラー表示がなくなっています. 例えば.WBのところであれば.以前であればバ
-
Using repo filelists (like with "pkgfile")
Arch's repositories provide lists of the files contained in each package. As far as I know, the only thing making use of that data is the "pkgfile" tool from community/pkgtools. Are there other such tools that I don't know about? It seems strange tha
-
just bought an n96 and for some reason is wont except my request to divert calls to mail box if busy. can someone help?
-
Help Needed in Message Driven Beans
Hi, I am using JMS and MDB for an asynchronuous communication. I configured the JMS on Sun App server successfully. But I am getting a error message for JNDI Naming. It is not able to find the MDB bean in the JNDI. So it is throwing a NameNotFoundExc