Return one row (DISTINCT) in a query BEX
Hi guru, i have this scenary:
one infoset on ods with timestamp field and material code
In the ODS i found many occurrence with same material code, but with many timestamp loading, es:
material timestamp
00AAA 20070301
00AAA 20070201
00BBB 20070101
in my query i want this result:
00AAA 20070301
00BBB 20070101
Can i have help for this troble ?
Thank's a lot.
Hi,
I think is not possible to do this in the query. I think you have to filter the ODS data. I would build another DSO and would filter the data in the transformation. If you buid another DSO you can include the master data and you wouldn't need the infoset.
Regards
Similar Messages
-
How just return one row of a one to many join..
So I have a one to many join where the SMOPERATOR table has data I need however it has a couple of rows that match the JOIN condition in there. I just need to return one row. I think this can be accomplished with a subquery in the join however have not been able to come up with the right syntax to do so.
So:
SELECT "NUMBER" as danumber,
NAME,
SMINCREQ.ASSIGNMENT,
SMOPERATOR.PRIMARY_ASSIGNMENT_GROUP,
SMOPERATOR.WDMANAGERNAME,
SMINCREQ.owner_manager_name,
SMINCREQ.subcategory, TO_DATE('01-'||TO_CHAR(open_time,'MM-YYYY'),'DD-MM-YYYY')MONTHSORT,
(CASE WHEN bc_request='f' THEN 'IAIO'
WHEN (bc_request='t' and substr(assignment,1,3)<>'MTS') THEN 'RARO'
WHEN (bc_request='t' and substr(assignment,1,3)='MTS') THEN 'M'
ELSE 'U' end) as type
from SMINCREQ
left outer join SMOPERATOR on SMINCREQ.assignment=SMOPERATOR.primary_assignment_group
WHERE SMINCREQ.owner_manager_name=:P170_SELECTION and SMOPERATOR.wdmanagername=:P170_SELECTION
AND open_time BETWEEN to_date(:P170_SDATEB,'DD-MON-YYYY') AND to_date(:P170_EDATEB,'DD-MON-YYYY')
AND
(bc_request='f' and subcategory='ACTIVATION' and related_record<>'t')
OR
(bc_request='f' and subcategory<>'ACTIVATION')
OR
(bc_request='t' and substr(assignment,1,3)<>'MTS')
order by OPEN_TIMeHi,
This sounds like a Top-N Query , where you pick N items (N=1 in this case) off the top of an orderded list. I think you want a separate ordered list for each assignment; the analytic ROW_NUMBER function does that easily.
Since you didn't post CREATE TABLE and INSERT statements for your sample data, I'll use tables from the scott schema to show how this is done.
Say you have a query like this:
SELECT d.dname
, e.empno, e.ename, e.job, e.sal
FROM scott.dept d
JOIN scott.emp e ON d.deptno = e.deptno
ORDER BY dname
;which produces this output:
DNAME EMPNO ENAME JOB SAL
ACCOUNTING 7934 MILLER CLERK 1300
ACCOUNTING 7839 KING PRESIDENT 5000
ACCOUNTING 7782 CLARK MANAGER 2450
RESEARCH 7876 ADAMS CLERK 1100
RESEARCH 7902 FORD ANALYST 3000
RESEARCH 7566 JONES MANAGER 2975
RESEARCH 7369 SMITH CLERK 800
RESEARCH 7788 SCOTT ANALYST 3000
SALES 7521 WARD SALESMAN 1250
SALES 7844 TURNER SALESMAN 1500
SALES 7499 ALLEN SALESMAN 1600
SALES 7900 JAMES CLERK 950
SALES 7698 BLAKE MANAGER 2850
SALES 7654 MARTIN SALESMAN 1250Now say you want to change the query so that it only returns one row per department, like this:
DNAME EMPNO ENAME JOB SAL
ACCOUNTING 7782 CLARK MANAGER 2450
RESEARCH 7876 ADAMS CLERK 1100
SALES 7499 ALLEN SALESMAN 1600where the empno, ename, job and sal columns on each row of output are all taken from the same row of scott.emp, though it doesn't really matter which row that is.
One way to do it is to use the analytic ROW_NUMBER function to assign a sequence of unique numbers (1, 2, 3, ...) to all the rows in each department. Since each sequence startw with 1, and the numbers are unique within a department, there will be exactly one row per departement that was assigned the numebr 1, and we''ll display that row.
Here's how to code that:
WITH got_r_num AS
SELECT d.dname
, e.empno, e.ename, e.job, e.sal
, ROW_NUMBER () OVER ( PARTITION BY d.dname
ORDER BY e.ename
) AS r_num
FROM scott.dept d
JOIN scott.emp e ON d.deptno = e.deptno
SELECT dname
, empno, ename, job, sal
FROM got_r_num
WHERE r_num = 1
ORDER BY dname
;Notice that he sub-query got_r_num is almost the same as the original query; only it has one additional column, r_num, in the SELECT clause, and the sub-qeury does not have an ORDER BY clause. (Sub-queries almost never have an ORDER BY clause.)
The ROW_NUMBER function must have an ORDER BY clause. In this example, I used "ORDER BY ename", meaning that, within each department, the row with the first ename (in sort order) will get r_num=1. You can use any column, or expression, or expressions in the ORDER BY clause. You muight as well use something consistent and predictable, like ename, but if you really wanted arbitrary numbering you could use a constant in the analytic ORDER BY clause, e.g. "ORDER BY NULL". -
How to return one ROW with Multiple value seperated by Colon in a SQL Query
Hi,
I have a SQL query as mentioned.
select deptno
from deptI want to mofidfy this query, so that this should return me department list with colon delimeted in one ROW.
10:20:30:40.......Thanks,
DeepakIn 10g:
select rtrim(xmlagg(xmlparse(content deptno || ':')).getstringval(), ':') data
from dept;
DATA
10:20:30:40with apologies for the abuse of XML... -
Returning one row in a view(only)
Is there any function that I can use to return just one row from a query?
I tryed the old LIMIT TO from rdb, but its useless...
I´m using a Oracle8Try using "where ROWNUM = 1" for the first row returned by the select
-
I apologize if this is a duplicate of some other post, but I'm not finding this exact scenario.
Assume that I have a table that looks like this:
select * from PROD_TABLE
PROD DESCRIPTION
1234 CANDLES
1234 CANDLE
1235 BRAKE PADS
1235 BRAKE PAD
(Yes, I know, I know, but it's for a POC, so dirty data will be cleaned up later.)
What I'd like to do is create a select statement that returns two rows from this table, one row for Prod 1234, one row for Prod 1235, and I DON'T CARE which description is returned for the corresponding Prod. For the POC, it's just not important which one is returned.
How can I craft the select statement?try this
SQL> with t as (select 1234 prod, 'CANDLES' dec from dual union all
2 select 1234 ,'CANDLE' dec from dual union all
3 select 1235 ,'BRAKE PADS' dec from dual union all
4 select 1235 ,'BRAKE PAD' dec from dual)
5 SELECT prod, DEC
6 FROM ( SELECT a.*
7 , ROW_NUMBER ( ) OVER ( PARTITION BY prod ORDER BY prod ) rn
8 FROM t a )
9 WHERE rn = 1
10 /
PROD DEC
1234 CANDLES
1235 BRAKE PADS
SQL> -
Result Set only returning one row...
When I run the following query in my program, I only get one row.
SELECT * FROM (SELECT * FROM ul_common_log_event WHERE application_name = 'Configuration' ORDER BY cle_id DESC) WHERE ROWNUM <= 500;
However when I run it in TOAD, I get all the rows I am looking for.
Here's my java
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);
My record set only contain one row. I am using Oracle 9 OCI driver BTW.
Any ideas? Thanks!Good thinking. That was the first thing I tried. That was not the problem. It turns out that I was stomping my rs object in another method. Problem resolved!
Thanks for the reply! -
Oracle view return more rows than its base query
O/S : AIX
Database : 11g R (11.1.0.6.0)
Query in questioon :
select A.CompanyCode, A.Code ElementCode, A.ItemTypeCode ElementItemTypeCode, A.SubcodeKey ElementSubcodeKey,
D.DecoSubcode01 SubCode01, D.DecoSubcode02 SubCode02, D.DecoSubcode03 SubCode03, D.DecoSubcode04 SubCode04,
D.DecoSubcode05 SubCode05, D.DecoSubcode06 SubCode06, D.DecoSubcode07 SubCode07, D.DecoSubcode08 SubCode08,
D.DecoSubcode09 SubCode09, D.DecoSubcode10 SubCode10, C.ItemTypeBCode, C.SubCode01B, C.SubCode02B, C.SubCode03B,
C.SubCode04B, C.SubCode05B, C.SubCode06B, C.SubCode07B, C.SubCode08B, C.SubCode09B, C.SubCode10B,
B1.ValueString SlipNo, B2.ValueString EmployeeCode, B3.ValueString SetNo, B4.ValueString SalesOrderCounterCode,
B5.ValueString SalesOrderCode, B6.ValueString Remarks, B7.ValueDecimal SumTareWeight, B8.ValueString PackingUMCode,
B9.ValueString PrimaryUMCode, B10.ValueString PlantCode, B11.ValueDecimal PackingFormCode, D.LogicalWarehouseCode FromWarehouseCode,
D.TemplateCode FromTemplateCode, D.PhysicalWarehouseCode FromPhysicalWarehouseCode, D.WHSLOCATIONWAREHOUSEZONECODE FromZoneCode,
D.WarehouseLocationCode FromLocationCode, E.LogicalWarehouseCode ToWarehouseCode, E.TemplateCode ToTemplateCode, E.PhysicalWarehouseCode ToPhysicalWarehouseCode,
E.WHSLOCATIONWAREHOUSEZONECODE ToZoneCode, E.WarehouseLocationCode ToLocationCode, D.TransactionDate, D.ItemTypeCode, E.WeightGross SumGrossWeight, E.WeightNet SumNetWeight
FROM Elements A, ADStorage B1, ADStorage B2, ADStorage B3, ADStorage B4, ADStorage B5, ADStorage B6, ADStorage B7,
ADStorage B8, ADStorage B9, ADStorage B10, ADStorage B11, GoodCutAndFentDetail C, StockTransaction D, StockTransaction E
where A.ABSUNIQUEID=B1.UNIQUEID and B1.NameEntityName='Elements' and B1.FieldName ='GoodCutAndFentSlipNo'
and A.ABSUNIQUEID=B2.UNIQUEID and B2.NameEntityName='Elements' and B2.FieldName ='GoodCutAndFentEmployee'
and A.ABSUNIQUEID=B3.UNIQUEID and B3.NameEntityName='Elements' and B3.FieldName ='GoodCutAndFentSetNo'
and A.ABSUNIQUEID=B4.UNIQUEID and B4.NameEntityName='Elements' and B4.FieldName ='GoodCutAndFentSOCounterCode'
and A.ABSUNIQUEID=B5.UNIQUEID and B5.NameEntityName='Elements' and B5.FieldName ='GoodCutAndFentSOCode'
and A.ABSUNIQUEID=B6.UNIQUEID and B6.NameEntityName='Elements' and B6.FieldName ='GoodCutAndFentRemarks'
and A.ABSUNIQUEID=B7.UNIQUEID and B7.NameEntityName='Elements' and B7.FieldName ='GoodCutAndFentTareWeight'
and A.ABSUNIQUEID=B8.UNIQUEID and B8.NameEntityName='Elements' and B8.FieldName ='GoodCutAndFentPackingUM'
and A.ABSUNIQUEID=B9.UNIQUEID and B9.NameEntityName='Elements' and B9.FieldName ='GoodCutAndFentPrimaryUM'
and A.ABSUNIQUEID=B10.UNIQUEID and B10.NameEntityName='Elements' and B10.FieldName ='GoodCutAndFentPlant'
and A.ABSUNIQUEID=B11.UNIQUEID and B11.NameEntityName='Elements' and B11.FieldName ='GoodCutAndFentPackingForm'
and A.CompanyCode=C.CompanyCode and SlipNo=C.SlipNo and C.SeqNo=1 and A.ItemTypeCode=C.ElementItemTypeCode
and A.SubcodeKey=C.ElementSubcodeKey and A.Code=C.ElementCode and A.CompanyCode=D.CompanyCode
and C.FromSTTransactionNumber=D.TransactionNumber and C.FromSTTransactionDetailNumber=D.TransactionDetailNumber
and A.CompanyCode=E.CompanyCode and C.ToSTTransactionNumber=E.TransactionNumber
and C.ToSTTransactionDetailNumber=E.TransactionDetailNumber
and SLIPNO='57575763636'
This query return 1 row.
Then i created a view on this query except condition SLIPNO='57575763636'
Now when i use the view as shown below return two rows.
select * from ViewGoodCutAndFent WHERE SLIPNO = '57575763636'
I am not able to determine where is problem area is. Thanks & RegardsIn the query SLIPNO is probably C.SlipNo
In the view SLIPNO is probably B1.ValueString -
This is part of SQL query in FROM clause:
select id, t, phase, time from measurement where phase=1 where id='1234'
This query can return more than one raw, but I need the only one, the latest one
I tried a lot of different stuff but no success!
ThanksGee, not sure if I got you right, but are you really sure that you need to do five (!) outer joins to your METNET table? Dont forget, each join, be it NESTED LOOPS, HASH or MERGE, requires extra CPU and I/O resources
Consider this query as a possible alternative:
SELECT tmh.heatid,
decode(tempcb.phase_id, 1, tempcb.t) cb,
decode(tempcb.phase_id, 2, tempcb.t) cb1,
decode(tempcb.phase_id, 3, tempcb.t) blow1,
decode(tempcb.phase_id, 4, tempcb.t) blow2,
decode(tempcb.phase_id, 5, tempcb.t) blow3
FROM heat_melt_proces_data hmpd,
tmelted_heats tmh,
(select t, sarza, phase_id
from metnet
where phase_id BETWEEN 1 AND 5) tempcb
WHERE hmpd.heatid=tmh.heatid
and tempcb.sarza (+) = tmh.heatid
and (to_char(hmpd.convertertappingendtime , 'YYYY-MM-DD HH24:MI') between '2006-06-10 22:30:01' and '2006-06-12 06:30:00')
order by tmh.heatid, hmpd.convertertappingendtime;And if I got you right regarding your TRANSFERTIME column, this is what you are looking for:
SELECT tmh.heatid,
decode(tempcb.phase_id, 1, tempcb.t) cb,
decode(tempcb.phase_id, 2, tempcb.t) cb1,
decode(tempcb.phase_id, 3, tempcb.t) blow1,
decode(tempcb.phase_id, 4, tempcb.t) blow2,
decode(tempcb.phase_id, 5, tempcb.t) blow3
FROM heat_melt_proces_data hmpd,
tmelted_heats tmh,
(select * from
(select t, sarza, phase_id,
row_number() over
(partition by sarza, phase_id order by transfertime desc) rn
from metnet
where phase_id BETWEEN 1 AND 5)
where rn = 1) tempcb
WHERE hmpd.heatid=tmh.heatid
and tempcb.sarza (+) = tmh.heatid
and (to_char(hmpd.convertertappingendtime , 'YYYY-MM-DD HH24:MI') between '2006-06-10 22:30:01' and '2006-06-12 06:30:00')
order by tmh.heatid, hmpd.convertertappingendtime;
Tip: converting DATEs into VARCHARs and using BETWEEN <varchar-const> AND <varchar-const> is generally an ouch-ouch approach. -
SQL-display two rows in a table as one row in the select query
Hi guys
Sorry if this sounds a little odd.
I have two tables
Im sorry but i tried to format these tables in text to make them look like tables but this text processor deletes space based formatting.
States
state id | Name
1 | california
2 | New york
3 | New hampshire
.......so on
Grades
Gradeid | State id | Language | Avgscore |
1 | 1 | ENG | 67 |
2 | 1 | FRENCH | 76 |
2 | 2 | SPANISH | 34 |
Now i wanna write an sql query thats gonna display like
State Name | State id | English | French | SPANISH|
California | 1 | 67 | 76 | null
New York | 2 | null | null | 34
I know how to get just an sql query where i can say
SELECT A.id, A.Name, G.Language,G.Avgscore
FROM States A , Grades G
where A.state_id = G.state_id
and G.Language = 'English'
How do i accomplish this?
Thanks
J
Edited by: user7348303 on Apr 1, 2010 1:15 PMRegarding:
Im sorry but i tried to format these tables in text to make them look like tables but this text processor deletes space based formatting.Use this tag: {noformat}{noformat}
before and after your example, so formatting will be maintained when posting your example.
Example, when you type:
{noformat}select * from dual;
{noformat}
it will appear as:select * from dual;
when you post it on the forum. -
How to find out which sub query returns more than one row
Hi all,
Can any one give me clue ,how to find out which sub query returns more than one row in the following query .
/* Formatted on 2011/05/17 19:22 (Formatter Plus v4.8.8) */
SELECT a.*, ROWNUM AS rnm
FROM (SELECT DISTINCT '1' AS "Page View", ou.org_unit_name AS "Org",
prxm.mbr_idntfr AS "Beneficiary ID",
md.last_name
|| ', '
|| md.first_name AS "Beneficiary Name",
pci.idntfr AS "Tracking No.",
TO_CHAR (TRUNC (req.pa_rqst_date),
'MM/dd/yyyy'
) AS "Request Date",
sts.status_name AS "Status",
req.pa_rqst_sid AS "Request #",
prxm.mbr_sid AS "Mbr_sid",
TO_CHAR
(TRUNC (req.pa_revision_date),
'MM/dd/yyyy'
) AS "Last Updated",
TO_CHAR (psd.TO_DATE, 'MM/dd/yyyy') AS "TO_DATE",
prxpl.prvdr_lctn_iid AS "PRVDR_LCTN_IID",
pd.prvdr_sid AS "PRVDR_SID", 'Y' AS "State View",
DECODE
((SELECT DISTINCT pd.national_prvdr_idntfr
FROM pa_request_x_provider_location prxplo
WHERE prxplo.pa_rqst_sid =
req.pa_rqst_sid
AND prxplo.oprtnl_flag = 'A'
AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
0, (SELECT prxplo.prvdr_lctn_idntfr
FROM pa_request_x_provider_location prxplo
WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
AND prxplo.oprtnl_flag = 'A'
AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
NULL, (SELECT prxplo.prvdr_lctn_idntfr
FROM pa_request_x_provider_location prxplo
WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
AND prxplo.oprtnl_flag = 'A'
AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
(SELECT DISTINCT pd.national_prvdr_idntfr
FROM pa_request_x_provider_location prxplo
WHERE prxplo.pa_rqst_sid =
req.pa_rqst_sid
AND prxplo.oprtnl_flag = 'A'
AND prxplo.pa_prvdr_type_lkpcd = 'RR')
) AS "NPI/ID",
DECODE
((SELECT pd.org_bsns_name
FROM pa_request_x_provider_location prxplo
WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
AND prxplo.oprtnl_flag = 'A'
AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
NULL, (SELECT pd.last_name
|| ', '
|| pd.first_name
|| ' '
|| pd.middle_name
FROM pa_request_x_provider_location prxplo
WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
AND prxplo.oprtnl_flag = 'A'
AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
(SELECT pd.org_bsns_name
FROM pa_request_x_provider_location prxplo
WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
AND prxplo.oprtnl_flag = 'A'
AND prxplo.pa_prvdr_type_lkpcd = 'RR')
) AS "Prvdr Name",
TO_CHAR (psd.from_date,
'MM/dd/yyyy'
) AS "Srvc From Date",
TO_CHAR (req.validity_start_date,
'MM/DD/YYYY'
) AS "Due Date",
(fn_get_busniess_days (TRUNC (req.validity_start_date))
) AS "Days<br>Left",
req.pa_mode_type_lkpcd AS "Source",
TO_CHAR (TRUNC (wmdtl.rtng_date),
'MM/dd/yyyy'
) AS "Assigned On",
NVL (wmdtl.assigned_to_user_name,
'Not Assigned'
) AS "Assigned To",
req.org_unit_sid AS "OrgUnitSid",
TO_CHAR
(wmdtl.modified_date,
'MM/dd/yyyy hh24:mi:ss'
) AS "WTRD_MODIFIED_DATE",
TO_CHAR (wmdtl.rtng_date,
'MM/dd/yyyy'
) AS "WTRD_RTNG_DATE",
req.status_cid AS "PA_STATUS_CID",
TO_CHAR (req.modified_date,
'MM/dd/yyyy'
) AS "PA_REQ_MODIFIED_DATE",
prs.state_pa_srvc_type_code
AS "STATE_PA_SRVC_TYPE_CODE",
wmdtl.wm_pa_task_rtng_dtl_sid
AS "WM_TASK_RTNG_DTL_SID",
wmdtl.assigned_to_user_acct_sid
AS "WTRD_Assigned_to_user_acct_sid",
(fn_get_busniess_days (TRUNC (req.validity_start_date))
) AS "Days<br>LeftSort",
wmdtl.assigned_to_org_unit_sid
AS "WTRD_Assigned_to_OrgUntSid",
DECODE
((SELECT COUNT (*)
FROM pa_request_status prs
WHERE prs.pa_rqst_sid = req.pa_rqst_sid
AND prs.status_cid = 5
AND prs.oprtnl_flag = 'I'),
0, 'N',
'Y'
) AS "SHOW_UTILIZATION"
FROM pa_request req,
pa_certification_identifier pci,
status sts,
pa_request_x_member prxm,
wm_pa_task_routing_detail wmdtl,
pa_service_date psd,
org_unit ou,
pa_request_service prs,
pa_request_x_provider_location prxpl,
provider_location pl,
provider_detail pd,
provider p,
mbr_dmgrphc md
WHERE req.oprtnl_flag = 'A'
AND req.status_cid NOT IN
(20, 30, 70, 25, 80, 96, 85, 5, 97, 98, 101)
AND req.org_unit_sid IN
(3057, 3142, 3058, 3143, 3059, 3144, 3060, 3145,
3061, 3146, 3062, 3147, 3063, 3148, 3064, 3149,
3065, 3150, 3066, 3151, 3067, 3152, 3068, 3153,
3069, 3154, 3070, 3155, 3071, 3156, 3072, 3157,
3073, 3158, 3074, 3159, 3075, 3160, 3076, 3161,
3077, 3162, 3078, 3163, 3079, 3164, 3080, 3165,
3081, 3166, 3082, 3167, 3083, 3168, 3084, 3169,
3085, 3170, 3086, 3171, 3087, 3172, 3088, 3173,
3089, 3174, 3090, 3175, 3091, 3176, 3092, 3177,
3093, 3178, 3094, 3179, 3095, 3180, 3096, 3181,
3097, 3182, 3098, 3183, 3099, 3184, 3100, 3185,
3101, 3186, 3102, 3187, 3103, 3003, 75000104,
75000108, 2006, 75000103, 75000102, 75000113,
75000111, 75000109, 2001, 2009, 75000105,
75000107, 2004, 2010, 2013, 2014, 2005, 2011,
75000112, 2002, 1001, 2012, 75000106, 2007,
75000101, 2003, 75000110, 2008, 3001, 3002, 3019,
3104, 3020, 3105, 3021, 3106, 3022, 3107, 3023,
3108, 3024, 3109, 3025, 3110, 3026, 3111, 3027,
3112, 3028, 3113, 3029, 3114, 3030, 3115, 3031,
3116, 3032, 3117, 3033, 3118, 3034, 3119, 3035,
3120, 3036, 3121, 3037, 3122, 3038, 3123, 3039,
3124, 3040, 3125, 3041, 3126, 3042, 3127, 3043,
3128, 3044, 3129, 3045, 3130, 3046, 3131, 3047,
3132, 3048, 3133, 3049, 3134, 3050, 3135, 3051,
3136, 3052, 3137, 3053, 3138, 3054, 3139, 3055,
3140, 3056, 3141)
AND req.pa_rqst_sid = prs.pa_rqst_sid
AND prs.oprtnl_flag = 'A'
AND prs.pa_rqst_srvc_sid = psd.pa_rqst_srvc_sid
AND psd.oprtnl_flag = 'A'
AND req.pa_rqst_sid = pci.pa_rqst_sid
AND pci.oprtnl_flag = 'A'
AND req.pa_rqst_sid = prxm.pa_rqst_sid
AND prxm.oprtnl_flag = 'A'
AND md.oprtnl_flag = 'A'
AND md.status_cid = 2
AND TRUNC (SYSDATE) BETWEEN md.from_date AND md.TO_DATE
AND prxm.mbr_sid = md.mbr_sid
AND ou.org_unit_sid = req.org_unit_sid
AND ou.oprtnl_flag = 'A'
AND req.pa_rqst_sid = prxpl.pa_rqst_sid
AND prxm.pa_rqst_sid = prxpl.pa_rqst_sid
AND pci.pa_rqst_sid = prxm.pa_rqst_sid
AND pci.pa_rqst_sid = wmdtl.subsystem_task_sid
AND pci.pa_rqst_sid = prxpl.pa_rqst_sid
AND prxpl.pa_prvdr_type_lkpcd = 'RR'
AND prxpl.oprtnl_flag = 'A'
AND req.status_cid = sts.status_cid
AND sts.status_type_cid = 3
AND sts.oprtnl_flag = 'A'
AND prxpl.prvdr_lctn_iid = pl.prvdr_lctn_iid
AND p.prvdr_sid = pd.prvdr_sid
AND p.prvdr_sid = pl.prvdr_sid
AND pd.oprtnl_flag = 'A'
AND pd.status_cid = 2
AND TRUNC (SYSDATE) BETWEEN pd.from_date AND pd.TO_DATE
AND wmdtl.subsystem_task_sid = req.pa_rqst_sid
AND wmdtl.subsystem_lkpcd = 'PA'
AND wmdtl.oprtnl_flag = 'A'
AND req.pa_rqst_date > (SYSDATE - 365)
ORDER BY TO_DATE ("Request Date", 'MM/dd/yyyy hh24:mi:ss') DESC,
"Beneficiary Name" ASC) a
WHERE ROWNUM < 102;regards,
P Prakash
Edited by: BluShadow on 17-May-2011 15:01
added {noformat}{noformat} tags around the code833560 wrote:
Can any one give me clue ,how to find out which sub query returns more than one row in the following query .This is why smaller, simpler queries are easier to work with than huge ones - when something like this goes wrong smaller queries are much eaiser to debug. Unfortunately using smaller, easier-to-work with queries is not always an option
Ganesh is right - you will have to dissect the big query bit by bit until you find the offending subquery. If there is another way I would like to find out about it too.
The easiest way to do this is probably to use block comments to isolate parts of the query bit by bit until you find the offending part. If you carefully examine the subqueries you might be able to figure out which one is returning multiple rows without commenting everything
Good luck! -
Report Builder 2.0 returning duplicate rows in query designer
Hi,
I have a query running off a model, when I explore the data in the model and in a standard sql table it returns one row for each record, which include a unique id for each which is correct.
When I go into report builder query designer, it shows duplicate rows for each record. I have removed and added fields to try and pin point why and the only reason i can come up with is that it runs fine until I add in a field thats varchar(255) or
varchar(max). This is when it starts to duplicate the records.
Can anyone tell me why it does this or point me in the direction of how to stop this. I can't edit the query in text to add DISTINCT so thats not an option.
Many thanks,
JJSJOK - I have found a partial answer. By Googling Report Builder and VARCHAR, I found another post which reported problems with the semantic query builder when the underlying table/view was returning columns of type VARCHAR(MAX).
On looking at the length setting for the data column in the DSV, this reported a length of 2,147,483,647 for this field. This is very odd because on querying the underlying table the largest length that I can find for this column is 191,086
(which is far larger than I would have expected - I am investigating this separately).
However, why should the Report Model think that this field contains such a large value?
Anyway, the other post that I found reported that they had solved their problem by converting the field to a VARCHAR (255). I tried this (by casting the column in my View to VARCHAR(255)) and this resolved the problem
- no more duplicate rows when adding this field to the query!!!
I also tried CASTING to TEXT and to VARCHAR(8000). The former did not resolve the problem; the latter did.
So I have a workaround but I don't understand why.
Can anybody explain why having a VARCHAR(max) column in my entity causes duplicate rows.
I suspect it is to do with the fact that for some reason the Report Model seems to think that there is an exceptionally long text string stored in this column in one of the rows but that again is a puzzle.
Thanks
Richard -
Ok. So, here is my issue, I am running a query on an oracle 10 database, through pl/sql developer. The result set returns something like this:
ID Code
A 001-012
A 001-021
A 001-032
A 001-043
B 001-023
B 001-054
B 001-003
B 001-002
B 001-007
I would like it to return this
ID Code
A 001-012
B 001-054
The "Code"(ex. 001-043) does not matter, only has to return one for each ID (ex. A), but has to return every unique ID. The problem with it is that there is no one common "Code" for each "ID".
I am sure this makes absolutely no sense...but if it does, and someone out there has any suggestions..would greatly appreciate it :)Shamrock wrote:
N Gasparotto wrote:
Shamrock wrote:
I would like it to return this
ID Code
A 001-012
B 001-054Why those two rows and not others instead ?
I mean, why not the two following ones ?
A 001-021
B 001-003
Are they getting randomly ?
Nicolas.That's the thing, it doesn't matter which row it picks, as long as it only returns one row for each ID. That's why I am struggling I think
Edited by: Shamrock on Jun 16, 2010 7:10 AMIf it doesn't matter which "code" it returns with the distinct "id", why select the "code" in the first place. You just said, in effect, it is meaningless.
just SELECT DISTINCT ID .... -
Report Queries - Multiple Source queries - One source returns & one doesn't
Hi Folks.
Odd one here.
I have a report query entry in the Shared Components of the APEX UI.
Within the Query are two source queries.
Both return unique column names.
Both use the same bind variable.
When generating a PDF using the call to the report, the data from one query is being returned and the data from another is not.
I have generated a sample XML file from APEX which is populated with data for both queries.
If I import this into MS-Word using the BIP plugin and generate a preview all is fine. All fields using data from both source queries are populated.
When generated via a regular call within APEX it simply does not work. I only get the data from one query.
Does anyone have any suggestions?
Anyone had a similar thing?
Any comments/suggestions welcome.
Many thanks
Dogfighter.
Message was edited by:
Dogfighter
Message was edited by:
DogfighterHi Marc
Does this make sense to you?
I have now set up a simple report query and report layout.
The record ID is hard coded into the query so that it only returns one row.
I am using an RTF based template.
If I navigate to Shared Components > Report Queries > Edit Report Query and then press the 'Test Report' button it runs perfectly.
If I copy the 'Print URL:' value from this page and use it as the URL target on any page in the app. it also works perfectly.
If I try and execute the following...
update invoice_summary
set invoice_pdf = APEX_UTIL.GET_PRINT_DOCUMENT (127, -- App ID
'TEST_INVOICE', -- query name
'TEST_INVOICE') -- layout name
where invoice_summary_gsm_id = a.INVOICE_ID;
I get the pdf saved to the BLOB column with the field labels in place but no data.
Three ways of running the report.
Two of them work perfectly but the one I want (generate direct into BLOB column) does not. Why would the exact same report query & report layout work with the other two methods but not the GET_PRINT_DOCUMENT route?
It's not as if the pdf does not get into the BLOB column, it does, but it only has the labels and no values.
Any ideas?
Simon.
PS. I only have one report query and one report layout set up so as to avoid confusion. Both with the same name.
Message was edited by:
Dogfighter -
[CLOSED] MAX returning two rows
Hi all,
I need to write a query that return 1 row.
If 'part 1' returns a value, the query needs to return null. If 'part 1' returns multiple values for latest_date, I need to return the latest of the dates.
Currently, this is the query I have. However this query returns more than 1 row.
Anny pointers are appreciated. Thanks
select Max(transaction_table.latest_date)
,transaction_table.status
from
---part 1
(select
sysdate latest_date
,'hello' status
from dual
UNION
--part 2
select
NULL latest_date
,NULL status
from dual) transaction_table
group by transaction_table.status;
RESULT:
MAX(TRANSACTION_TABLE.LATEST_DATE) STATUS
17-MAR-08 hello
2 rows selected
Message was edited by:
user594688
THANK YOU for all the repliesHi,
max funtion never returns two rows :-)
If 'part 1' returns a value, the query needs to
return null. If 'part 1' returns multiple values for
latest_date, I need to return the latest of the
dates.It can't dual always return 1 row.
So, why do you need part 2?
>
Currently, this is the query I have. However this
query returns more than 1 row.
This will make your query return one row, but that's probably not what you want:
SQL> with md AS
2 (select max(latest_date) max_date
3 from
4 ---part 1
5 (select sysdate latest_date
6 ,'hello' status
7 from dual
8 UNION
9 --part 2
10 select NULL latest_date
11 ,NULL status
12 from dual))
13 select transaction_table.*
14 from md
15 ,(select sysdate latest_date
16 ,'hello' status
17 from dual
18 UNION
19 select NULL latest_date
20 ,NULL status
21 from dual) transaction_table
22 where md.max_date = transaction_table.latest_date;
LATEST_DA STATU
17-MAR-08 hello
1 row selected.Regards
Peter -
Hi,
I have a graphical program that repaints every 2000 ms. I want to call another program that queries the Oracle dbase and returns one row at a time, so that in the graphical program, I see the value of the next row every 2000 ms. Any ideas on how I'd do this?
I have the basics on resultsets and statements and using while(rs.next()), etc.. Thanks. Chris.Insert "Thread.sleep(2000);" at places where you want your program to wait for 2000 milliseconds.
Maybe you are looking for
-
Black ink not printing in 3545 e-All-in-O​ne Printer
Hi, Black does not print. Colour/image prints fine. Eg. In a word document, the images (if any) print fine, but the text does not. If there is only text, the printed sheet is blank. Model - HP Deskjet Ink Advantage 3545 e-All-in-One Printer
-
ITunes 10.1.2 not starting after update
iTunes will not start after being updated to 10.1.2. Also experienced internet explorer being extremely slow. Tried to repair the installation, but same result. Uninstalled iTunes, restarted the computer, and internet explorer started working again.
-
IPhoto Database on shared HD linked to AEBS
Hi When I put an iPhoto database on a shared HD (LaCie 320 GB) linked via AEBS, the response time of iPhoto is very very slow. I use Ethernet cables to connect, and it is still to slow. Mac os 10,4,10 - iPhoto 6 and iPhoto buddy to select the databas
-
Is it possible to use a wildcard SSL cert on an ASA? That is, instead of getting a specific cert with the FQDN of the ASA, we would use the wildcard cert issued?
-
gr_sorts type ref to cl_salv_sorts. gr_sorts = gr_table->get_sorts( ). gr_sorts->add_sort( columnname = 'MATNR' sequence = if_salv_c_sort=>sort_down subtotal = abap_true ). Take a look at these statements. sequence has been assigned a contant of