Regarding Doubt in Query
Hi Friends,
I have a doubt in Oracle Query.
Query
SELECT ID FROM LIST;
ResultSet
1
2
3
4
5
789
In the above query the result will in seperate rows, bu i want it as
1,2,3,4,5.............,789.
Can anyone help me to write a query for this type of output.
Thanks,
Dick....
with t as(select 1 col1 from dual
union select 2 from dual
union select 3 from dual
union select 4 from dual
union select 5 from dual
union select 6 from dual)
select ltrim(max(sys_connect_by_path(to_char(col1),',')),',') col1
from (select col1,
row_number() over(order by col1) r1,
row_number() over(order by col1)-1 r2
from t)
start with r1 = 1
connect by prior r1=r2;
Similar Messages
-
Hi all:
I have a doubt in Query ...
I have an infocube for GR quantities and other infocube for confimation quantities.
In a multiprovider,i collect this two cubes.In query designer,if i given GR date as i/p,
confirmation quantities doesnt display.IF i didnt give GR date as i/p,then both GR and Confimation
quantities display in seperate line.In that case if i see the confirmation quantitis column,GR quantity is
and same for GR quanitiy.
Waiting for your inputs.
Rgds
MSKMSK,
These two pieces of information are at different levels. GR Date is mapped only to the GR quantities cube and no mapped to the confirmation quantities cube.
Map GR date in the multi-provider to a date in the confirmation quantities cube.
Aneesh -
Doubt regarding flashback versions query
I am working with Oracle 10g database on Oracle Enterprise Linux
I was trying this query both as sysdba and connected as the respective user .
When connected as sysdba I was of course appending schema name to the table name while running the query so there were no errors.
SELECT VERSIONS_STARTTIME, VERSIONS_ENDTIME
FROM emp_data
VERSIONS BETWEEN TIMESTAMP MINVALUE AND MAXVALUE
ORDER BY VERSIONS_STARTTIME ;
VERSIONS_STARTTIME VERSIONS_ENDTIME But unfortunately the query is returning null .
Let me know if any parameter has to be enabled for the query to work or what went wrong. The table of course has many transactions running and I was able to get the change through ora_rowscn but flashback versions query was the one not working.
Let me know if I have missed anythingPrabu,
If the transaction is still going on means they are not yet committed than Versions query won't show you anything.Also if you have surpassed the Undo_retention andhave most probably lost the required undo data,you wont be able to get any output from it.So check these two things.There are no special parameters required to use this feature except for automatic undo management and Undo retention.
In the meantime,you may also want to look at this link for a simple description of this and other flashback features,
http://www.oracle-base.com/articles/10g/Flashback10g.php
HTH
Aman.... -
Doubt in query statement in receiver jdbc
HI
Again a doubt in XML format for receiver jdbc.
I want to execute a query
select sum(col1) sum(col2) from tablename where startdate <= tdate.
My payload message looks like this
<AggregateFn action="SQL_QUERY">
<access>SELECT sum(Weight) FROM KmFuelTrace WHERE resourceno = '$resno$' AND startdate = '$sdate1$'</access>
- <key>
<resno compareOperation="EQ">CHILLED_02</resno>
<sdate1 compareOperation="LT">06/08/2007</sdate1>
</key>
</AggregateFn>
I am getting a error "Data type mismatch in criteria expression" .
I have defined the datatypes correctly with DateTrans function . I think its the problem with access statement.
How to give the selection criteria for non-text fields. (can i use same quotes and dollar combination for date field too) . Or is there any other mistake in the xml structureAarthi,
Try the following
<AggregateFn action="SQL_QUERY">
<access>SELECT sum(Weight) FROM KmFuelTrace WHERE resourceno = '$resno$' AND startdate = $sdate1$</access>
- <key>
<resno compareOperation="EQ">CHILLED_02</resno>
<sdate1 compareOperation="LT">06/08/2007</sdate1>
</key>
</AggregateFn>
Also check what us the date format that database uses and give the similar format.
Regards,
Sudharshan N A
Message was edited by:
Sudharshan Aravamudan -
Need help regarding "saving a query"
Hi BW gurus,
I have a few doubts.
I developed few queries in the DEV and i transported to QA.
Since DEV was not having much data i could visualize the report(graphical report) if it meets my reporting specs.
So i made the query changes directly in the QA system, and i created a workbook,which contains plenty of Excel work and macros programming.Now my report is ready in QA.
These are my doubts
1.Can my queries and workbooks be transported to PROD without any problem from QA?
2.I tried to make the similar changes to the queries in DEV ,and i tried to save it,but i got an error on the Query Designer window stating that,the query cannot be saved due to a problem in the transport?
Tell me what are the ways to solve my problems
Thanks in Advance,
Have a nice day
Regards
SMHi Sam,
When you need to make any changes to any object BEx related or AWB objects, the changes have to be first made in the dev system and then transported to QA. If there is a difference between the QA and the dev system the transports might fail.
And as you already got the solution. Create a BEx Transport Request in Transport Connection and then make the changes to the query and save. Then you can transport the same to qa and prod without any issue.
How this helps.
NewBW -
Doubts in Query & Infoset Builder
Hi All,
I have a problem/doubt with my query, Due to a requirement I have to place a Check box in my Selection scree of Query.
Unfortunately when I place my Checkbox in Info-set(SQ02), Its showing check Box at first place.
Example:
We have a Query with selection screen fields as
MBLNR
MJAHR
MATNR
MENGE
Now When I add a Checkbox in SQ02 & when I run the report, I am getting this Checkbox, at Top of selection screen.
Actually I am looking to have this Check box after my selection-screen elements.
I tried with Sequence on selection-screen, but its only working with the fields declared in Selections.
Is there any chance like I can declare my Selection screen parameters in the position I want.
Please advice me.
Thanks,
Dileep .Cuser10447332 wrote:
(!)select * from emp where rownum>5
it wont give o/p/what is the reason.
if we mention rownum<=5 then it gives o/p what is the reasonIts because rownum is applied to the row at the last stage of fetch. It is applied to the row which would be displayed to the user. So after your row is ready to be shown to the requester, it is assigned rownum as 1 and then oracle checks if it is greater than 5. Since the result is false, this row is rejected and next row is given rownum as 1 and checked again. Since all rows would fail (as all rows would be assigned as rownum 1) you would get no rows selected.
(2)
i have two data bases. i want to import 2 tables from database1 to data base2.how to do it.
Well you can use
- exp/imp
expdp/impdp
copy commmand
db link
(3)i have servers at 3 locations us,uk,asia.
if data is changed in one server.it should reflect in all servers.
if we query from any server we have to get same result how to do it.You can use
materialized view
oracle streams
3rd party tool like golden gate
(4)
i have data in excel file.i want to load data from excel file int o my tavble .how to do it(dont use sql loader)I only know sql loader as a way to do it
Regards
Anurag -
Help required regarding tunning the query mentioned
HI all ,
Query mentioned below takes around 1 hr to complete . It's being used by the autoconfig kindly me in tunning it ..
QUery :
UPDATE WF_ITEM_ATTRIBUTE_VALUES WIAV SET WIAV.TEXT_VALUE = REPLACE(WIAV.TEXT_VALUE,:B1,:B2)
WHERE (WIAV.ITEM_TYPE, WIAV.NAME) = (SELECT WIA.ITEM_TYPE, WIA.NAME
FROM WF_ITEM_ATTRIBUTES WIA WHERE WIA.TYPE = 'URL'
AND WIA.ITEM_TYPE = WIAV.ITEM_TYPE
AND WIA.NAME = WIAV.NAME)
AND WIAV.TEXT_VALUE IS NOT NULL
AND INSTR(WIAV.TEXT_VALUE
, :B1) > 0
Plan :*
<pre>
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | UPDATE STATEMENT | | 453 | 14496 | 284K|
| 1 | UPDATE | WF_ITEM_ATTRIBUTE_VALUES | | | |
|* 2 | FILTER | | | | |
|* 3 | TABLE ACCESS FULL | WF_ITEM_ATTRIBUTE_VALUES | 453 | 14496 | 282K|
|* 4 | TABLE ACCESS BY INDEX ROWID| WF_ITEM_ATTRIBUTES | 1 | 33 | 2 |
|* 5 | INDEX UNIQUE SCAN | WF_ITEM_ATTRIBUTES_PK | 1 | | 1 |
Predicate Information (identified by operation id):
2 - filter(("SYS_ALIAS_2"."ITEM_TYPE","SYS_ALIAS_2"."NAME")= (SELECT /*+ */
"WIA"."ITEM_TYPE","WIA"."NAME" FROM "APPLSYS"."WF_ITEM_ATTRIBUTES" "WIA" WHERE
"WIA"."NAME"=:B1 AND "WIA"."ITEM_TYPE"=:B2 AND "WIA"."TYPE"='URL'))
3 - filter("SYS_ALIAS_2"."TEXT_VALUE" IS NOT NULL AND
INSTR("SYS_ALIAS_2"."TEXT_VALUE",:Z)>0)
4 - filter("WIA"."TYPE"='URL')
5 - access("WIA"."ITEM_TYPE"=:B1 AND "WIA"."NAME"=:B2)
</pre>
Index :*
<pre>
INDEX_NAME COLUMN_NAME
APPLSYS WF_ITEM_ATTRIBUTE_VALUES_PK 1 ITEM_TYPE
2 ITEM_KEY
3 NAME
</pre>
regds
Rahul
Edited by: RahulG on Jan 2, 2009 10:47 PM
Edited by: RahulG on Jan 2, 2009 10:48 PMRahulG wrote:
HI all ,
Query mentioned below takes around 1 hr to complete . It's being used by the autoconfig kindly me in tunning it ..
A few notes:
1. Your query is using bind variables. If you're already on 9i or later (probably 9iR2 according to plan output), this statement will be subject to bind variable peeking and therefore the output of EXPLAIN PLAN is only of limited use, since the actual execution plan might be different and/or might be based on different cardinality estimates based on the actual bind values peeked at hard parse time. You can use the V$SQL_PLAN view to get the actual execution plan(s) if the statement is still cached in the shared pool, from 10g on DBMS_XPLAN.DISPLAY_CURSOR is available for that purpose.
2. The execution plan posted suggests that only 453 rows will correspond to the filter criteria (but, as mentioned in 1. is based on an unknown bind variable value when using EXPLAIN PLAN), and probably therefore the optimizer didn't unnest the subquery but runs this as recursive FILTER query potentially for each row passing the filter criteria on the driving table WF_ITEM_ATTRIBUTE_VALUES. Depending on the actual number of rows this might be inefficient, and unnesting the subquery and turning it into a join might be more appropriate. This might accomplished e.g. by providing more representative statistics to the optimizer (are the statistics up-to-date?).
Although you can't change the SQL you could try this manually by using the UNNEST hint to see if it makes any difference in the execution plan (and run time):
WHERE (WIAV.ITEM_TYPE, WIAV.NAME) = (SELECT /*+ UNNEST */ WIA.ITEM_TYPE, WIA.NAME
...3. The composite index WF_ITEM_ATTRIBUTE_VALUES_PK can only be used on the first column ITEM_TYPE for effective index access, the NAME column would have to be used as filter on all index leaf blocks that would be found using a range scan on ITEM_TYPE. This might be quite inefficient, and/or might lead to a lot of rows/blocks that need to be visited in the table using this index access path.
4. You could try to trace the execution by enabling extended SQL trace, e.g. using the (undocumented) DBMS_SUPPORT package in 9i. Running the "tkprof" utility on the generated trace file tells you the actual row source cardinalities (which can then be compared to the estimates of the optimizer) and - if the "waits" have been enabled - what your statement has waited for most.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/ -
Doubt in Query(on 28th)
Hi all
I wrote the following query
SELECT COUNT(DISTINCT QUESTION_ID) AS QCOUNT,
DECODE(((SUM(SUM(WORK_SPACE))/5)*100)/QCOUNT,<50,COUNT(DISTINCT RESPONSER_ID)) AS COUNT1,
DECODE(((SUM(SUM(WORK_SPACE))/5)*100)/QCOUNT,>=50 AND <=60,COUNT(DISTINCT RESPONSER_ID)) AS COUNT2,
DECODE(((SUM(SUM(WORK_SPACE))/5)*100)/QCOUNT,>=60 AND <=75,COUNT(DISTINCT RESPONSER_ID)) AS COUNT3,
DECODE(((SUM(SUM(L.WORK_SPACE))/5)*100)/QCOUNT,>75,COUNT(DISTINCT RESPONSER_ID)) AS COUNT4
FROM TQDB_LEARNER_RESPONSE
Can i use QCOUNT IN DECODE Function.
I am getting 'Missing Expression Error"
Is thr any other alternative to write this query
Regards.Hi Thanks for reply.
I have changed my query as following.
SELECT
CASE WHEN (((SUM(DISTINCT WORK_SPACE)/5)*100)/COUNT(DISTINCT QUESTION_ID))<50 THEN COUNT(DISTINCT RESPONSER_ID) ELSE NULL END AS COUNT1,
CASE WHEN (((SUM(DISTINCT WORK_SPACE)/5)*100)/COUNT(DISTINCT QUESTION_ID))>=50 AND (((SUM(WORK_SPACE)/5)*100)/COUNT(DISTINCT QUESTION_ID)) <=60 THEN COUNT(DISTINCT RESPONSER_ID) ELSE NULL END AS COUNT2,
CASE WHEN (((SUM(DISTINCT WORK_SPACE)/5)*100)/COUNT(DISTINCT QUESTION_ID))>=60 AND (((SUM(WORK_SPACE)/5)*100)/COUNT(DISTINCT QUESTION_ID)) <=75 THEN COUNT(DISTINCT RESPONSER_ID) ELSE NULL END AS COUNT3,
CASE WHEN (((SUM(DISTINCT WORK_SPACE)/5)*100)/COUNT(DISTINCT QUESTION_ID))>75 THEN COUNT(DISTINCT RESPONSER_ID) ELSE NULL END AS COUNT4
FROM TQDB_LEARNER_RESPONSE
Will it work for AND Condition(>=50 and <=60)
Pls Help me -
Hi Experts,
I have a select query as follows:
select field1 field2 from db1 into table it1.
Now suppose the it1-field1 contains values a,b and c.
Now I want to select fields a,b and c from another db table db2.
Instead of hard coding like this:
select a b c from db2 into table it2.....
How can I do this?
Points will be awarded.
Regards,
Soumya.Hi Soumya ,
Pleas use FOR ALL ENTRIES syntax , in this way you can select the records from db2 which are available or selected in db1.
Like Header And Item table.
You select records frm header table . then for corres ponding header records you select from detail table db2 .....
Condition is the field containg a,b,c is key field in both tables ...
Reward points if it helps you .
Regards
Amber S -
Regarding "select into" query and "no data found" exception
So i have included the following into my procedure:
select div_cd into c_div_cd
from division_tab d, emp_tab y
where d.div_name=y.div_text and y.emp_code=d.emp_code;
and also an exception
exception
when no data found
-- print something
The above select query results into "no data found" and the control passes directly to the exception and prints something.
How do I do the following?
select div_cd into c_div_cd
from division_tab d, emp_tab y
where d.div_name=y.div_text and y.emp_code=d.emp_code;
if c_div_cd is null then
--enter this employee into some other table without raising an exception
No need to write a code for an answer. Please just guide me with something I can incorporate or do.use explicit cursors
DECLARE
c_div_cd division_tab.div_cd%type;
cursor c_div is
select div_cd
from division_tab d, emp_tab y
where d.div_name=y.div_text and y.emp_code=d.emp_code;
BEGIN
open c_div;
fetch c_div into c_div_cd;
--You can either use c_div%NOTFOUND or c_div_cd is null in the below if condition to check the data
-- Note if your select query returns multiple records then you have to do mutiple fetches for getting all records, so in that case your FETCH
-- should be inside the LOOP statement
if c_div_cd is null then
--enter this employee into some other table without raising an exception
end if;
close c_div;
EXCEPTION
IF c_div%ISOPEN then
close c_div;
END IF;
END;
Regards
JJ -
Regarding HR ABAP (query selction)
Hai Experts,
if i give the month and date means , I need to display all the values for all years.
for example if i give month as may and then date as 15 means then i need the values for all years for that corresponding month and date upto system date.
With Regards,
R.Dhineshraj.one way would be to create two additional fields (month, day) in infoset of 2 characters one for month, one for day.
Then in record processing write
for e.g. your infotype is 0000 then the code will be
data var_date(4) type c.
concatenate month day into var_date.
check p0000-begda-4(4) = var_date.
add the fields month and day in the field group and assign it in the query (tcode sq01).
Then select them in sq01 to be shown for selection.
This should solve your problem. -
Problem regarding user defined query
I have a problem with Formatted Search in the Item table of the Order window.
We got some extra functionality for our Indian subsidiary and they are provided via Formatted Searches.
So for example there is one SQL statement with mathematical computations like (don't ask! SQL is not for mathematics, i would do this with SDK!)
snip ###
if $[RDR1.Itemcode]= '880000000000'
SELECT (convert(decimal(16,2),$[RDR1.U_V_Width])convert(decimal(16,2),$[RDR1.U_V_Height])convert(decimal(16,2),$[RDR1.U_Qty_Nos]))/1000000
else
select ((select slength1 from oitm where itemcode=$[RDR1.Itemcode]) * $[RDR1.U_Qty_Nos]) from oitm where itemcode= $[RDR1.ItemCode]
snip ###
The Search is defined with:
Search by saved query
Auto Refresh when exiting altered column Qty(Nos)
Display saved values
If i have only one line, all theses queries (5) are computed in just a second. But if there are 20 or more it takes 20 seconds to compute!
It feels like all fields of all rows will be computed again if i change one of the corresponding fields!
What can i do to minimize waiting period for the user?Hi Frank,
This may be the current limiting factor in using formatted searches at the line level. There are known performance issues with using formatted searches in this way with the UI slowly grinding to a halt as the number of rows on the document increases. The situation gets worse if formatted searches are combined with an add-on that uses the validate event on row fields. Is it correct that your main company (without formatted searches) gets better performance?
The only workaround is not to use formatted searches :-\
I've heard the situation is better in SBO 2007A but I haven't tested it myself.
Kind Regards,
Owen -
Doubts in query ..
Hi Genius,
I have a doupts in Report..
<b> budat = 01.04.2007 to 30.04.2007</b>
<b> matnr = a001</b>
SELECT * FROM zs_mkpf_mseg
into corresponding fields of table it_opbal
WHERE werks = itmat-werks
AND matnr = itmat-matnr
AND budat LT s_budat-low.
Now iam getting the opening balance..that is the closing balance of up to
30-3-2007.
My req is..between 1st month to 30th, i have to calculate the opbal of every day wise(1-4-07 to 30-4-07) for that how i should write the query statement.
please suggest me.Hi
SELECT gjahr belnr FROM bseg
into corresponding fields of table int_bseg
WHERE werks = itmat-werks
AND budat = s_budat-low.
loop at int_BSEG.<-- loop at ur date declared internal table
read table int_bseg WITH KEY BELNR = INT_BSEG-BELNR
GJAHR = INT_BSEG-GJAHR. <-- to read the same internal table
IF int_bseg-belnr = 'compare value'.
total = total + int_bseg-belnr. " here goes ur coding part for date "
try like thi s
Reward all helpfull answers
Regards
Pavan -
Hi Guriji,s
I wrote one inner join query. it is working fine. but when i exceute this query it is fetching the data only 261 movement type but but i also fetch the data movement type 201. for this plz tell me the correction in this query.
select amatnr awerks abwart bbudat into table t_itab from mseg as a inner join mkpf as b
on amblnr = bmblnr
where awerks in plant and abwart = '261' or a~bwart = '201'
and btcode2 = 'mb1a' or btcode2 = 'mfbf' .
thanks.Hi Sachin
try to use like below
select amatnr awerks abwart bbudat into table t_itab from mseg as a inner join mkpf as b
on amblnr = bmblnr
where awerks in plant and ( abwart = '261' or a~bwart = '201' )
and ( btcode2 = 'mb1a' or btcode2 = 'mfbf' ).
or try to fill ranges like select-options or use like
select amatnr awerks abwart bbudat into table t_itab from mseg as a inner join mkpf as b
on amblnr = bmblnr
where awerks in plant and abwart in ('261', '201')
and btcode2 = 'mb1a' or btcode2 = 'mfbf' .
Regards
Praveen -
Doubts about Query Builder tool
Hi!
We are using database link and the developed querys have many schemas.
There is possible to use the Query Builder tool for multi Database schemas? How to do?
There is possible to create query in Query Builder tool using database link? How to do?
I would like to know about Query Builder tool in the our activies.
*If there is more information about it(Query Builder tool) or documentations, please talk to me.
Best Regards,
Priscila Brittohi.
try this [http://sourceforge.net/projects/sqleonardo/|http://sourceforge.net/projects/sqleonardo/]
maybe it can help you.
Maybe you are looking for
-
How To Set Parameters in a SOAP-Message for QUERY_VIEW_DATA Web Service
Hi all, I want to use the QUERY_VIEW_DATA Web Service to get data from BI through an existing BEx-query. How can I set a navigation status as it is stated in the SAP documentation [Web Service for Accessing Query Data|http://help.sap.com/saphelp_nw04
-
1 TB Stor.E TV - Folders are empty
Hi, I hope for your assistance. I have a 1TB Store.E.TV. Attached at the PC, all folders and files which I copied on it appear. But during the connection at my television there are no more all folders or the folders are empty. Can please someone say
-
BAPI or FM for Unloading Pallets
Hi All, I need to create a RF program that will be used to unload pallets just like std sap transaction Lm30 and needs to update the HU status just like LM30 does. Can someone suggest any BAPI or FM that can be used to unload Pallets . Thanks..!!!
-
Hi, we have SAP EHP 2 for SAP NetWeaver 7.0/sql server 2005 on win server 2005. I have implemented the CPRXRPM add-on. For the PPM user i have given the following roles: SAP_BCV_USER SAP_BPR_PPM SAP_CPR_BCV_USER SAP_CPR_BCV_USER_COMP SAP_CPR_USER SAP
-
All of the layout and text disappeared from a book I'd been working on. ??
any clue how to retrieve it? i think the program asked me to sync, save or backup. When I rebooted, it is gone.