SelectOneChoice with Distinct Values of Same ViewObject as Table
JDev 11.1.1.6
Scenario:
One database table (MyTable) with 2 columns (MyDate and MyValue).
MyDate | MyValue
31-JUL-13 | 5.00
31-JUL-13 | 10.00
30-JUN-13 | 20.00
30-JUN-13 | 13.00
I need a page that has a selectOneChoice with a distinct list of MyDate and a table that displays only records associated with the selected date.
So, the user should be able to select 30-JUN-13 from the selectOneChoice and the table should refresh with just the 2 records for that date.
I am sure I am over-thinking this but do I need to create 2 entities? If so, how can I create an entity for a distinct list from a table?
Can I accomplish this with 2 view objects?
Is there an easier way (like using an LOV on the Entity Attribute)?
Any advise would be appreciated.
Ray
No, one EO will be enough. On this you build two VO one with the distinct query and one with the exact date query.
Timo
Similar Messages
-
How to create a table with distinct values ?
I want to create a new table based on an existing table distinct values only, how can I avoid to create the duplicate values ?
e.g.
table1
field1 field2
0001 ABD
0001 ABD
0002 DCF
0002 DCF
new table
field1 field2
0001 ABD
0002 DCF
thankscreate table table2
as
select distinct field1,field2
from table1 -
Row To Column with distinct values
Hi Oracle Gurus,
Please help me on this regard.
A table has columns statuscode,reasoncode,date with valid values as
statuscode -> status1,status2,status3,status4,status5
reasoncode -> a,b,c,d,e
Date will be passed by runtime.
Requirement is to take the stage report of statuscode by reasoncode.
i.e., if status1 has value in reason it has to show the count else return null for eg. if status1 statuscode has a, b reasoncode report wil show like below.
a b c d e
status1 1 1
status2 2 2 1
status3 4 5 5 2 3
status4 3 2 2
status5 2 2
Advanace thanx for the GurusIsn't this a duplicate to the following thread posted by another user?
Rows into columns -
What is '#Distinct values' in Index on dimension table
Gurus!
I have loaded my BW Quality system (master data and transaction data) with almost equivalent volume as in Production.
I am comparing the sizes of dimension and fact tables of one of the cubes in Quality and PROD.
I am taking one of the dimension tables into consideration here.
Quality:
/BIC/DCUBENAME2 Volume of records: 4,286,259
Index /BIC/ECUBENAME~050 on the E fact table /BIC/ECUBENAME for this dimension key KEY_CUBENAME2 shows #Distinct values as 4,286,259
Prod:
/BIC/DCUBENAME2 Volume of records: 5,817,463
Index /BIC/ECUBENAME~050 on the E fact table /BIC/ECUBENAME for this dimension key KEY_CUBENAME2 shows #Distinct values as 937,844
I would want to know why the distinct value is different from the dimension table count in PROD
I am getting this information from the SQL execution plan, if I click on the /BIC/ECUBENAME table in the code. This screen gives me all details about the fact table volumes, indexes etc..
The index and statistics on the cube is up to date.
Quality:
E fact table:
Table /BIC/ECUBENAME
Last statistics date 03.11.2008
Analyze Method 9,767,732 Rows
Number of rows 9,767,732
Number of blocks allocated 136,596
Number of empty blocks 0
Average space 0
Chain count 0
Average row length 95
Partitioned YES
NONUNIQUE Index /BIC/ECUBENAME~P:
Column Name #Distinct
KEY_CUBENAMEP 1
KEY_CUBENAMET 7
KEY_CUBENAMEU 1
KEY_CUBENAME1 148,647
KEY_CUBENAME2 4,286,259
KEY_CUBENAME3 6
KEY_CUBENAME4 322
KEY_CUBENAME5 1,891,706
KEY_CUBENAME6 254,668
KEY_CUBENAME7 5
KEY_CUBENAME8 9,430
KEY_CUBENAME9 122
KEY_CUBENAMEA 10
KEY_CUBENAMEB 6
KEY_CUBENAMEC 1,224
KEY_CUBENAMED 328
Prod:
Table /BIC/ECUBENAME
Last statistics date 13.11.2008
Analyze Method 1,379,086 Rows
Number of rows 13,790,860
Number of blocks allocated 187,880
Number of empty blocks 0
Average space 0
Chain count 0
Average row length 92
Partitioned YES
NONUNIQUE Index /BIC/ECUBENAME~P:
Column Name #Distinct
KEY_CUBENAMEP 1
KEY_CUBENAMET 10
KEY_CUBENAMEU 1
KEY_CUBENAME1 123,319
KEY_CUBENAME2 937,844
KEY_CUBENAME3 6
KEY_CUBENAME4 363
KEY_CUBENAME5 691,303
KEY_CUBENAME6 226,470
KEY_CUBENAME7 5
KEY_CUBENAME8 8,835
KEY_CUBENAME9 124
KEY_CUBENAMEA 14
KEY_CUBENAMEB 6
KEY_CUBENAMEC 295
KEY_CUBENAMED 381Arun,
The cube in QA and PROD are compressed. Index building and statistics are also up to date.
But I am not sure what other jobs are run by BASIS as far as this cube in production is concerned.
Is there any other Tcode/ Func Mod etc which can give information about the #distinct values of this Index or dimension table?
One basic question, As the DIM key is the primary key in the dimension table, there cant be duplicates.
So, how would the index on Ftable on this dimension table show #distinct values less than the entries in that dimension table?
Should the entries in dimension table not exactly match with the #Distinct entries shown in
Index /BIC/ECUBENAME~P on this DIM KEY? -
Running report from command line with multiple value for same parameter
Hey,
I know how to run a report from the command line specifying parameters values each time but I was wondering if someone could tell me how I would go about running the same report multiple times in a batch program but specifying a list of values to pass to a parameter each time.
So for example if a parameter was 'School Number', how could I run a report in a batch program that would pass a school number to the report as a parameter using a list of school numbers generated for a sql statement or something. So if I had 300 school numbers in my list then I would get 300 different reports when the batch program finished.
This leads me to another question. How can I dynamically change the name of the report generated by the batch to use the school number value passed in, so for example if the value 3 was passed in the name would be something like School 3.pdf, if 4 was passed in the name would be School 4.pdf....etc
Any help on this?
ThanksHello,
Bursting and Distribution may help you ....
37 Bursting and Distributing a Report
http://download-uk.oracle.com/docs/cd/B14099_17/bi.1012/b13895/orbr_dist.htm
Regards -
Hi, I have this query in my 9ir2 database:
SELECT xmit.u_ii_id, xprol.ii_id
FROM xprol, ( SELECT DISTINCT u_ii_id, ii_id
FROM t
WHERE NVL(key_t,'X') <> 'P') xmit
WHERE xprol.ii_id = xmit.ii_id
AND xmit.u_ii_id <> xprol.ii_id ;
u_ii_id ii_id
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
6220 5765
7898 3409
7898 3409
7898 3409
7898 3409
7898 3409
7898 3409
7898 3409
7898 3409
.The query returns 12.294.938 million of rows.
I need to know de best way to filter this values... maybe using Analytic Functions?
The result of the query must be...
u_ii_id ii_id
6220 5765
7898 3409Thanks!ROW_NUMBER () OVER (PARTITION BY xmit.u_ii_id
ORDER BY xmit.u_ii_id,
xprol.ii_id) AS rn
xprol, (SELECT DISTINCT u_ii_id, ii_id
FROM t
HERE NVL (key_t, 'X') <> 'P') xmit
WHERE xprol.ii_id = xmit.ii_id AND xmit.u_ii_id <>
xprol.ii_id AND rn = 1
/code]this will not work it will give , that needs to be in subquery
ORA-00904: "RN": invalid identifier
below is just an example
SQL> select empno,e.deptno ,row_number() over(partition by deptno order by deptno) rn
2 from emp e, (select deptno from dept1
3 where deptno=10) d
4 where e.deptno=d.deptno
5 and rn=1;
and rn=1
ERROR at line 5:
ORA-00904: "RN": invalid identifier
/pre] -
SelectOneChoice with static Value
I want to create a simple selectOnechoice . I create input form that include :
name : _________ => I use af:inputText
department : _________ => I use af:selectOneChoice, that is a static list following code:
<af:selectOneChoice value="#{bindings.PersonEntryDepartment.inputValue}" label="department" id="selectOneDepartment" unselectedLabel="select department">
<af:selectItem label="Computer Science" value="0" binding="#{addPerson.selectItem1}" id="selectItem1"/>
<af:selectItem label="Science" value="1" binding="#{addPerson.selectItem2}" id="selectItem2"/>
</af:selectOneChoice>
when I click ok , I get value
name = value that I entered
department = null
How to get value from af:selectOneChoice, I want to receive department's value is 0 or 1Hi,
try setting valuePassThrough on the selectOneChoice to "true"
Frank -
Binding UI controls with different RowSets in same ViewObject
Hi,
I have a ViewObject vEmp and created two RowSet rowSet1 and rowSet2 for vEmp.
What I want to do is to bind two different JList to these RowSets. These RowSets contain different data as I have used Named Bind Variables.
Can anybody please explain me how can I achieve this?
Thanks.Hi,
if you use ADF Swing then you do this through the binding layer.
1) Open the pageDef file of your ADF Swing application
2) In the executable section, create a second iterator for the VO
3) Set the RSIName property of this second iterator to the name of the RowSetIterator created in code
4) Create the list box and use the second rowset iterator for the list
Frank -
Elementary Search help with distinct values. Kindly help!
Hi Experts,
I have to create a search help for Plant field. The Plant field is in a custom table YPLANT_DET. Unfortunately the plant field in this table is not unique.
So the elementary search help will show duplicate plant entries.
How to customize the elementary search help so that I get only distict values on F4 help?
KIndly help!
Thanks
GopalHi,
You need to use Search help exit...
i am attaching below sample code..write the select query at appropriate location and pass the internal table to sub FM mentioned in the code..
Code Sample
BEGIN OF CODE SAMPLE -
BEGIN OF INCLUDE LZSHLPTOP -
FUNCTION-POOL zshlp. "MESSAGE-ID ..
TYPE-POOLS shlp.
TYPES:
BEGIN OF t_knvp,
kunnr TYPE kna1-kunnr,
name1 TYPE kna1-name1,
ort01 TYPE ort01_gp,
stras TYPE stras_gp,
kunn2 TYPE knvp-kunn2,
name1_2 TYPE kna1-name1,
END OF t_knvp.
DATA: i_knvp TYPE TABLE OF t_knvp,
wa_knvp TYPE t_knvp,
wa_selopt TYPE ddshselopt,
wa_fielddescr TYPE dfies.
DATA:
rc TYPE i,
v_tabix LIKE sy-tabix.
RANGES: r_ktokd FOR kna1-ktokd,
r_mcod1 FOR kna1-name1,
r_sortl FOR kna1-sortl,
r_kunnr FOR kna1-kunnr,
r_ort01 FOR kna1-ort01.
END OF INCLUDE LZSHLPTOP -
BEGIN OF FUNCTION MODULE Z_CUSTOM_SEARCH -
FUNCTION z_custom_search.
""Local interface:
*" TABLES
*" SHLP_TAB TYPE SHLP_DESCR_TAB_T
*" RECORD_TAB STRUCTURE SEAHLPRES
*" CHANGING
*" VALUE(SHLP) TYPE SHLP_DESCR_T
*" VALUE(CALLCONTROL) LIKE DDSHF4CTRL STRUCTURE DDSHF4CTRL
EXIT immediately, if you do not want to handle this step
CASE callcontrol-step.
STEP SELECT (Select values)
This step may be used to overtake the data selection completely.
To skip the standard seletion, you should return 'DISP' as following
step in CALLCONTROL-STEP.
Normally RECORD_TAB should be filled after this step.
WHEN 'SELECT'.
Change column header texts appearing on the search help hit list
LOOP AT shlp-fielddescr INTO wa_fielddescr.
v_tabix = sy-tabix.
CASE wa_fielddescr-fieldname.
WHEN 'KUNNR'.
wa_fielddescr-fieldtext = 'ShipToCustomer#'.
wa_fielddescr-reptext = 'ShipToCustomer#'.
wa_fielddescr-scrtext_s = 'ShipTo #'.
wa_fielddescr-scrtext_m = 'ShipToCustomer#'.
wa_fielddescr-scrtext_l = 'ShipToCustomer#'.
MODIFY shlp-fielddescr FROM wa_fielddescr
INDEX v_tabix TRANSPORTING fieldtext reptext scrtext_s
scrtext_m scrtext_l.
WHEN 'KUNN2'.
wa_fielddescr-reptext = 'BillToCustomer#'.
wa_fielddescr-fieldtext = 'BillToCustomer#'.
wa_fielddescr-scrtext_s = 'BillTo #'.
wa_fielddescr-scrtext_m = 'BillToCustomer #'.
wa_fielddescr-scrtext_l = 'BillToCustomer #'.
MODIFY shlp-fielddescr FROM wa_fielddescr
INDEX v_tabix TRANSPORTING fieldtext reptext scrtext_s
scrtext_m scrtext_l.
WHEN 'NAME1'.
wa_fielddescr-fieldtext = 'ShipToCustomer Name'.
wa_fielddescr-reptext = 'ShipToCustomer Name'.
wa_fielddescr-scrtext_s = 'ShipTo Name'.
wa_fielddescr-scrtext_m = 'ShipToCustomer Name'.
wa_fielddescr-scrtext_l = 'ShipToCustomer Name'.
MODIFY shlp-fielddescr FROM wa_fielddescr
INDEX v_tabix TRANSPORTING fieldtext reptext scrtext_s
scrtext_m scrtext_l.
ENDCASE.
ENDLOOP.
Select the Bill to party customer based on the select options
FREE: r_ktokd, r_kunnr, r_sortl, r_mcod1, r_ort01, i_knvp.
LOOP AT shlp-selopt INTO wa_selopt.
Build a Range for the 5 selection options of the search help
CASE wa_selopt-shlpfield.
WHEN 'KTOKD'.
r_ktokd-sign = wa_selopt-sign.
r_ktokd-option = wa_selopt-option.
r_ktokd-low = wa_selopt-low.
r_ktokd-high = wa_selopt-high.
APPEND r_ktokd.
CLEAR r_ktokd.
WHEN 'KUNNR'.
r_kunnr-sign = wa_selopt-sign.
r_kunnr-option = wa_selopt-option.
r_kunnr-low = wa_selopt-low.
r_kunnr-high = wa_selopt-high.
APPEND r_kunnr.
CLEAR r_kunnr.
WHEN 'SORTL'.
r_sortl-sign = wa_selopt-sign.
r_sortl-option = wa_selopt-option.
r_sortl-low = wa_selopt-low.
r_sortl-high = wa_selopt-high.
APPEND r_sortl.
CLEAR r_sortl.
WHEN 'MCOD1'.
r_mcod1-sign = wa_selopt-sign.
r_mcod1-option = wa_selopt-option.
r_mcod1-low = wa_selopt-low.
r_mcod1-high = wa_selopt-high.
APPEND r_mcod1.
CLEAR r_mcod1.
WHEN 'ORT01'.
r_ort01-sign = wa_selopt-sign.
r_ort01-option = wa_selopt-option.
r_ort01-low = wa_selopt-low.
r_ort01-high = wa_selopt-high.
APPEND r_ort01.
CLEAR r_ort01.
ENDCASE.
ENDLOOP.
Retrieve data from KNVP table for the above selected ranges
Doing query to retrieve data for the search help
SELECT knvp~kunnr
kna1~name1
kna1~ort01
kna1~stras
knvp~kunn2
INTO TABLE i_knvp
FROM knvp
INNER JOIN kna1
ON knvpkunnr = kna1kunnr
WHERE
knvp~parvw = 'RE' AND " Bill to Party
knvp~kunnr IN r_kunnr AND
kna1~ktokd IN r_ktokd AND
kna1~sortl IN r_sortl AND
kna1~mcod1 IN r_mcod1 AND
kna1~ort01 IN r_ort01.
CHECK sy-subrc = 0.
DELETE ADJACENT DUPLICATES FROM i_knvp.
Select the short text for kunn2 from kna1.
Move all the selected records to Record_Tab
LOOP AT i_knvp INTO wa_knvp.
v_tabix = sy-tabix.
SELECT SINGLE name1 FROM kna1
INTO wa_knvp-name1_2
WHERE kunnr = wa_knvp-kunnr.
MOVE wa_knvp TO record_tab-string.
APPEND record_tab.
CLEAR record_tab.
MODIFY i_knvp FROM wa_knvp INDEX v_tabix.
CLEAR wa_knvp.
ENDLOOP.
rc = 0.
IF rc = 0.
callcontrol-step = 'DISP'.
ELSE.
callcontrol-step = 'EXIT'.
ENDIF.
EXIT. "Don't process STEP DISP additionally in this call.
WHEN 'PRESEL1'.
WHEN 'DISP'.
WHEN OTHERS.
ENDCASE.
ENDFUNCTION.
END OF FUNCTION MODULE Z_CUSTOM_SEARCH -
END OF CODE SAMPLE -
Save and activate at every step.
Regards,
Chandra
(Award points if helpful) -
Concatenate columns with distinct values in oracle
Hello Gurus,
My table structre look like follwoing:
TankListUS TankListCanada TankListIndia
T111||T222 T444||T222 T555
Now when I run the query:
select (TL.TankListUS || '||' || TL.TankListCanada || '||' || TL.TankListIndia)as "OverallSummary" from TankListTL
I get output as
T111||T222||T444||T222||T555
But I don't need duplicate of tanks. I need my output as:
T111||T222||T444||T555
Is this possible?May be this can be done in regexp..
If you are in 11g, I just tried hard way... (split, remove dups and concatenate again....) -- not elegant, but works for your test case. (this can be simplified as well )
WITH t AS
(SELECT 'T111||T222' tanklistus,
'T444||T222' tanklistcanada,
'T555' tanklistindia
FROM DUAL),
tt AS
(SELECT REPLACE (
TL.TankListUS
|| ','
|| TL.TankListCanada
|| ','
|| TL.TankListIndia,
'||',
OverallSummary
FROM t tl),
ttt AS
( SELECT LEVEL lvl,
REGEXP_SUBSTR (tt.OverallSummary,
'[^,]+',
1,
LEVEL)
LETTER
FROM tt
CONNECT BY LEVEL <= REGEXP_COUNT (tt.OverallSummary, ',') + 1)
SELECT listagg (letter, '||') WITHIN GROUP (ORDER BY lvl) str
FROM (SELECT lvl,
ROW_NUMBER () OVER (PARTITION BY letter ORDER BY 1) rnk,
letter
FROM ttt)
WHERE rnk = 1
Output:
STR
T111||T222||T444||T555
Cheers,
Manik. -
Selecting rows with null values in an sql 3 table
Hi everyone I use oracle database 11g and have the following SQL statement:
SELECT Oprema.Opr_Id, Oprema.Datum_Nabavke, Oprema.Datum_Zaduzenja, Oprema.Dobavljac, Oprema.Jedinica_Mjere,
coalesce ((Oprema.Zaduzio), 0), Oprema.Vrijednost, Oprema.Kolicina_Nabavna, Oprema.Kolicina_Otpisana, Oprema.Kolicina_Trenutna, Oprema.Status, Oprema.Konto,
Oprema.KontoIsp, Oprema.Broj_Naloga, Oprema.Sifra_Objekta, Dobavljaci.Naziv AS DobNaz, coalesce(to_char(Uposlenici.Prezime), 'hm'), Objekti.Objekat_ID
FROM OPREMA Oprema, UPOSLENICI Uposlenici, DOBAVLJACI Dobavljaci, OBJEKTI Objekti
WHERE Oprema.Dobavljac=Dobavljaci.Dob_Id AND Oprema.Zaduzio=Uposlenici.UposlenikId AND Oprema.Sifra_Objekta=Objekti.Objekat_IDWhat I need is to show all the rows in the database. The problem is that some of the foreign keys Zaduzio and Objekti are NULL. This means the databse won't show those and only shows me rows where both have values. In all of these rows except for 3 only one of the two foreign keys has a value.
So what I need is an sql that would show me all 3. As you can see I tried with Coallesce but it didn't work, still only 3 rows show.
I also tried with UNION
SELECT Oprema.Opr_Id, Oprema.Datum_Nabavke, Oprema.Datum_Zaduzenja, Oprema.Dobavljac, Oprema.Jedinica_Mjere,
Oprema.Zaduzio, Oprema.Vrijednost, Oprema.Kolicina_Nabavna, Oprema.Kolicina_Otpisana, Oprema.Kolicina_Trenutna, Oprema.Status, Oprema.Konto,
Oprema.KontoIsp, Oprema.Broj_Naloga, Oprema.Sifra_Objekta, Dobavljaci.Naziv AS DobNaz, Uposlenici.Prezime, Objekti.Objekat_ID
FROM OPREMA Oprema, UPOSLENICI Uposlenici, DOBAVLJACI Dobavljaci, OBJEKTI Objekti
WHERE Oprema.Dobavljac=Dobavljaci.Dob_Id AND Oprema.Zaduzio=Uposlenici.UposlenikId AND Oprema.Sifra_Objekta=Objekti.Objekat_IDBut then the rows that have both Zaduzio and Objekti values are multiplied and selected twice.
So any ideas on how to do this?Hi,
If those foreign keys are NULL, then an inner join won't produce any results. Maybe you need to make it an outer-join, like this:
SELECT Oprema.Opr_Id
, Oprema.Datum_Nabavke
, Oprema.Datum_Zaduzenja
, Oprema.Dobavljac
, Oprema.Jedinica_Mjere
, COALESCE ( Oprema.Zaduzio
, 0
) AS zaduzio_or_0
, Oprema.Vrijednost
, Oprema.Kolicina_Nabavna
, Oprema.Kolicina_Otpisana
, Oprema.Kolicina_Trenutna
, Oprema.Status
, Oprema.Konto,
Oprema.KontoIsp
, Oprema.Broj_Naloga
, Oprema.Sifra_Objekta
, Dobavljaci.Naziv AS DobNaz
, COALESCE ( TO_CHAR (Uposlenici.Prezime)
, 'hm'
) AS prezime_or_hm
, Objekti.Objekat_ID
FROM OPREMA
JOIN DOBAVLJACI ON Oprema.Dobavljac = Dobavljaci.Dob_Id
LEFT OUTER JOIN UPOSLENICI ON Oprema.Zaduzio = Uposlenici.UposlenikId
LEFT OUTER JOIN OBJEKTI ON Oprema.Sifra_Objekta = Objekti.Objekat_ID
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
Simplify the problem. For example, if you really need to display 18 columns, but 15 of them have nothing to do with the problem, then post a question that just includes e or 4 of those columns.
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ {message:id=9360002} -
Sql query slowness due to rank and columns with null values:
Sql query slowness due to rank and columns with null values:
I have the following table in database with around 10 millions records:
Declaration:
create table PropertyOwners (
[Key] int not null primary key,
PropertyKey int not null,
BoughtDate DateTime,
OwnerKey int null,
GroupKey int null
go
[Key] is primary key and combination of PropertyKey, BoughtDate, OwnerKey and GroupKey is unique.
With the following index:
CREATE NONCLUSTERED INDEX [IX_PropertyOwners] ON [dbo].[PropertyOwners]
[PropertyKey] ASC,
[BoughtDate] DESC,
[OwnerKey] DESC,
[GroupKey] DESC
go
Description of the case:
For single BoughtDate one property can belong to multiple owners or single group, for single record there can either be OwnerKey or GroupKey but not both so one of them will be null for each record. I am trying to retrieve the data from the table using
following query for the OwnerKey. If there are same property rows for owners and group at the same time than the rows having OwnerKey with be preferred, that is why I am using "OwnerKey desc" in Rank function.
declare @ownerKey int = 40000
select PropertyKey, BoughtDate, OwnerKey, GroupKey
from (
select PropertyKey, BoughtDate, OwnerKey, GroupKey,
RANK() over (partition by PropertyKey order by BoughtDate desc, OwnerKey desc, GroupKey desc) as [Rank]
from PropertyOwners
) as result
where result.[Rank]=1 and result.[OwnerKey]=@ownerKey
It is taking 2-3 seconds to get the records which is too slow, similar time it is taking as I try to get the records using the GroupKey. But when I tried to get the records for the PropertyKey with the same query, it is executing in 10 milliseconds.
May be the slowness is due to as OwnerKey/GroupKey in the table can be null and sql server in unable to index it. I have also tried to use the Indexed view to pre ranked them but I can't use it in my query as Rank function is not supported in indexed
view.
Please note this table is updated once a day and using Sql Server 2008 R2. Any help will be greatly appreciated.create table #result (PropertyKey int not null, BoughtDate datetime, OwnerKey int null, GroupKey int null, [Rank] int not null)Create index idx ON #result(OwnerKey ,rnk)
insert into #result(PropertyKey, BoughtDate, OwnerKey, GroupKey, [Rank])
select PropertyKey, BoughtDate, OwnerKey, GroupKey,
RANK() over (partition by PropertyKey order by BoughtDate desc, OwnerKey desc, GroupKey desc) as [Rank]
from PropertyOwners
go
declare @ownerKey int = 1
select PropertyKey, BoughtDate, OwnerKey, GroupKey
from #result as result
where result.[Rank]=1
and result.[OwnerKey]=@ownerKey
go
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Portal Forms - How to make a Field with DEFAULT value NON-EDITABLE by Users
I HAVE A FORM WITH A DATE FIELD ON IT WITH DEFAULT VALUE.
THIS IS A TABLE-FIELD.
I WANT THE FIELD TO BE DISPLAYED ON THE FORM BUT NOT TO ALLOW
USERS TO EDIT/CHANGE IT.
HOW CAN I DO THIS?
TKS IN ADVANCEHi,
see Re: sequencing problem-Forms
Regards Michael -
2 independent selectOneChoice with the same value
So I have two selectOneChoice with the same list values but different methodAction and methodIterator.
when i change one's item and correspond to value, changing the other's item and value automatic, why?
what is wrong? I'll send the code fragment
How to make 2 independent list from the same business method?
Jspx file
<af:selectOneChoice value="#{bindings.*test1*.inputValue}"
label="#{bindings.*test1*.label}">
<f:selectItems value="#{bindings.*test1*.items}"/>
</af:selectOneChoice>
<af:selectOneChoice value="#{bindings.*test2*.inputValue}"
label="#{bindings.*test2*.label}">
<f:selectItems value="#{bindings.*test2*.items}"/>
</af:selectOneChoice>
the pagedefinition file is
<executables>
<methodIterator id="*queryTestIter*"
Binds="*queryTest.result*"
DataControl="SessionEJB1Local" RangeSize="-1"
BeanClass="project1.DependentStrings"/>
<methodIterator id="*queryTestIter1*"
Binds="*queryTest1.result"*
DataControl="SessionEJB1Local" RangeSize="-1"
BeanClass="project1.DependentStrings"/>
</executables>
<bindings>
<methodAction id="*queryTest*"
InstanceName="SessionEJB1Local.dataProvider"
DataControl="SessionEJB1Local"
MethodName="*methodOne*"
RequiresUpdateModel="true" Action="999"
IsViewObjectMethod="false"
ReturnName="SessionEJB1Local.methodResults.SessionEJB1Local_dataProvider_queryTest_result">
</methodAction>
<methodAction id="*queryTest1*"
InstanceName="SessionEJB1Local.dataProvider"
DataControl="SessionEJB1Local"
MethodName="*methodOne*"
RequiresUpdateModel="true" Action="999"
IsViewObjectMethod="false"
ReturnName="SessionEJB1Local.methodResults.SessionEJB1Local_dataProvider_queryTest1_result">
</methodAction>
<list id="*test1*" IterBinding="findallItemIter"
StaticList="false" ListOperMode="0"
ListIter="*queryTestIter*">
<AttrNames>
<Item Value="*item1Id*"/>
</AttrNames>
<ListAttrNames>
<Item Value="id"/>
</ListAttrNames>
<ListDisplayAttrNames>
<Item Value="stringValue"/>
</ListDisplayAttrNames>
</list>
<list id="*test2*" IterBinding="findallItemIter"
StaticList="false" ListOperMode="0"
ListIter="*queryTestIter1*">
<AttrNames>
<Item Value="*item2Id*"/>
</AttrNames>
<ListAttrNames>
<Item Value="id"/>
</ListAttrNames>
<ListDisplayAttrNames>
<Item Value="stringValue"/>
</ListDisplayAttrNames>
</list>there is a list with different listIter's value,but it dos't work
<list id="test1" IterBinding="findallItemIter"
StaticList="false" ListOperMode="0"
ListIter="queryTestIter">
<AttrNames>
<Item Value="item1Id"/>
</AttrNames>
<ListAttrNames>
<Item Value="id"/>
</ListAttrNames>
<ListDisplayAttrNames>
<Item Value="stringValue"/>
</ListDisplayAttrNames>
</list>
<list id="test2" IterBinding="findallItemIter"
StaticList="false" ListOperMode="0"
ListIter="queryTestIter1">
<AttrNames>
<Item Value="item2Id"/>
</AttrNames>
<ListAttrNames>
<Item Value="id"/>
</ListAttrNames>
<ListDisplayAttrNames>
<Item Value="stringValue"/>
</ListDisplayAttrNames>
</list>
Edited by: user638080 on Sep 9, 2008 12:22 AM -
How to get real value from selectOneChoice with javascript?
Hi,
How to get real value from selectOneChoice with javascript? The event.getNewValue() only gets me the index of the selected item, not the value/title.
JSF page:
<af:resource type="javascript">
function parseAddress(event)
alert("new value: " + event.getNewValue());
</af:resource>
<af:selectOneChoice label="Location:" value="" id="soc4">
<af:clientListener type="valueChange" method="parseAddress" />
<f:selectItems value="#{Person.locations}" id="si7"/>
</af:selectOneChoice>
HTML :
<option title="225 Broadway, New York, NY-10007" selected="" value="0">225 Broadway (Central Office)</option>
<option title="90 Mark St., New York, NY-10007" value="1">90 Mark St. (Central Office)</option>
Thanks a lot.Something I was missing ,
You need to add valuePassThru="true" in your <af:selectOneChoice component. I have personally tested it and got the actual value in alert box. I hope this time you got the real solution. You can also test the following code by your end.
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document id="d1">
<af:form id="f1">
<af:panelBox text="PanelBox1" id="pb1">
<af:selectOneChoice label="Set Log Level" id="soc1"
value="#{SelectManagedBean.loggerDefault}"
valuePassThru="true">
<af:selectItem label="select one" value="First" id="s6"/>
<af:selectItem label="select two" value="Second" id="s56"/>
<af:clientListener method="setLogLevel" type="valueChange"/>
</af:selectOneChoice>
<af:resource type="javascript">
function setLogLevel(evt) {
var selectOneChoice = evt.getSource();
var logLevel = selectOneChoice.getSubmittedValue();
// var logLevelObject = AdfLogger.NONE;
alert("new value is : " + logLevel);
//alert(evt.getSelection);
//alert(logLevelObject);
evt.cancel();
</af:resource>
</af:panelBox>
</af:form>
</af:document>
</f:view>
</jsp:root>
Maybe you are looking for
-
I have an external drive dedicated for Time Machine, it's 2 TB. Last year I started backing up computer (500 GB) and one external hard drive that has 500 GB. IAlso, I have another external drive that is 1 TB connected to my computer. I noticed last w
-
[SOLVED] Amarok 2 make fails
Hi, I'm trying to install Amarok 2 via yaourt with this package: http://aur.archlinux.org/packages.php?ID=19633 However, it fails with several errors. I've done some searching, but I can't find any solution that's helpful to me/one I understand (st
-
How to get fully qualified name for a class with just the class name
I want to get the fully qualified name of the class at runtime. The only piece of information which I have is the class name. I want to create a runtime instance of a class with the class name [Just the class name]. Is there is any way to achieve thi
-
Problem with file sharing - Lion to Mountain Lion
I have two MBP's. One is running Lion (2011 vintage), the other is running Mountain Lion (2012 vintage). They are connected on my home network as follows: MBP with Lion --> Ethernet cable --> D-Link Router --> Airport Extreme MBP with Mountain Lio
-
Resource for BO on Win and Linux
Hi, I have a BusinessObjects project. Can you give me requirements resource for BO on Linux and Window?? Thanks Duypm