Analytical query output
I have one table having the following entries
RCSCID ITEM STATUS
00001 RCE1 AA
00002 RCE1 AA
00003 RCE1 AA
00005 RCE1 AA
00006 RCE1 AA
The output i require is
RCSCID ITEM STATUS
00001-00003 RCE1 AA
00005-00006 RCE1 AA
Pl help me in getting it
For the small sample you provided this may give you a startsql>
select min(id)||'-'||max(id) id,min(item) item,min(status) status
from(
select id,item,status,sum(lg) over(order by to_number(id)) sm
from(
select id,item,status,
case to_number(id) -
nvl(lag(id) over(order by to_number(id)),
lead(id) over(order by to_number(id)))
when 1 then 0
when -1 then 0
else 1 end lg
from test))
group by sm;
ID ITEM STATUS
00001-00003 RCE1 AA
00005-00006 RCE1 AA
Message was edited by:
jeneesh
@OP:
ID is assumed of same size always, in the above logic.So
to_number in order by is not needed.
When more item and status comes partition by clause must
be added.
Similar Messages
-
Analytic query to select next record
Hi all,
I would like to query the below two table match to ouput.
1.dev_wt 2.dev_map 3.Output Result
To help more clearance please see this image link : http://lh6.ggpht.com/_xL6eBqjW6Yo/TEqnSvlF_FI/AAAAAAAAB0U/i2sclnnaj6g/Untitled-3.jpg
1. dev_wt
PMS_COMP PMS_I PMS_PERF_D PMS_WT PMS_CREATION_D
BBOARD GICEQGROSS 04/01/2001 30 04/05/2001
BBOARD GICST_B 04/01/2001 5 04/05/2001
BBOARD SBGS_B 04/01/2001 65 04/05/2001
BBOARD GICEQGROSS 04/11/2001 30 04/15/2001
BBOARD GICST_B 04/11/2001 5 04/15/2001
BBOARD SBGS_B 04/11/2001 65 04/15/20012. dev_map
GS_CODE GS_I_CODE GS_I_ID MD_ID GS_START_DT GS_END_DT
GICEQGROSS CIWL 304 15 01/04/1998 31/03/2004
GICEQGROSS CIWL 304 2 01/04/2004 31/03/9998
GICST_B GICST_B 3707 15 01/04/2000 31/12/9998
SBGS_B SBGS_B 2231 15 01/04/1992 30/09/2003
SBGS_B SBGS_B 564 15 01/10/2003 31/12/9998I would like to match PMS_I = GS_CODE to retrieve GS_I_CODE and using analytic
query to find next record.
Because I need to select GICEQGROSS record of PMS_PERF_D date and next
GICEQGROSS record of PMS_PERF_D from dev_wt table and put GS_WT_FR and GS_WT_TO of Output result.
***Date is change to YYYYMMDD format
***PMS_WT is devided by 100
*3. Output Result*
GS_I_ID PMS_COMP GS_I_CODE GS_WT_FR GS_WT_TO GS_I_CALC
304 BBOARD CIWL 20010401 20010410 0.3
3707 BBOARD GICST_B 20010401 20010410 0.05
5209 BBOARD SBGS_B 20010401 20010410 0.65PMS_COMP is from dev_wt table
GS_I_CODE is from dev_map table join with dev_wt
GS_WT_FR is from dev_wt table of GS_START_DT
GS_WT_TO is from dev_wt table of next record GS_START_DT where PMS_I ='GICEQGROSS'
Now my difficulty is to select next record of PMS_PERF_D using analytic query. Below
is my query...
SELECT GS_I_ID, PMS_COMP, GS_I_CODE, GS_WT_FR, GS_WT_TO, GS_I_CALC
FROM dev_wt (
SELECT lead(PMS_PERF_D) over(partition by PMS_I order by PMS_PERF_D) as GS_WT_TO
FROM dev_wt where PMS_I ='GICEQGROSS')
left join dev_map on PMS_I = GS_CODE ;Thanks
Edited by: WinZone on Jul 24, 2010 4:46 PM
Edited by: WinZone on Jul 24, 2010 4:50 PMHi,
This query should be fine:
SELECT DISTINCT t2.gs_i_id, pms_comp, t2.gs_i_code,
TO_CHAR
(MIN (pms_perf_d) OVER (PARTITION BY pms_comp, pms_i),
'yyyymmdd'
) gs_wt_fr,
TO_CHAR
(MAX (pms_perf_d) OVER (PARTITION BY pms_comp, pms_i) - 1,
'yyyymmdd'
) gs_wt_to,
pms_wt / 100 gs_i_calc
FROM dev_wt t1, dev_map t2
WHERE t2.gs_code = t1.pms_iREM Same remark as odie: should be "2231" instead ... -
Hi All,
i have used CMS in SQL 2008 R2. i have added couple of servers in its group. i have executed a query & i need to send the query output in the form of email.
basically query is checking the rows count from couple of user tables in servers.
issue here is how to copy the data that is used by CMS? i need to work on automate the rows count in difft user table in db servers
could you please suggest how can i achieve this?Copy to what?
SELECT COUNT(*) FROM sys.objects
Running the above statement returns two columns (server name and count)
All the servers SS2005 and onwards , then use
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'name',
@recipients = '[email protected]',
@query = 'SELECT COUNT(*) FROM sys.objects',
@subject = 'Count rows'
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 -
ERROR displaying in the query output... urgetn
hi experts,
For the amount keyfigures in the query output it displaying ERROR after the amount like ex- 2000 ERROR.
plz let me know how to rectify this..
regards
vadlamudihi,
i have created only two keyfigures EMP_BASIC and EMP_HRA. and in the transformations i have mapped with 0DOC_CURRCY.
but in the report its showing ERROR only after the amount. plz tell me exactly with what field i need to map???
regards
vadlamudi -
Hello Gurus,
I am having an issue with query output.Please find below the details of it
Unsold claims: Total---> 200
Dispatch: Total--->118,086
Unsold claims/dispatch--->0.001694
This should be the output but its coming --.0033120 because itu2019s dividing with max value in dispatch which is 60,386.
Reason: The aggregation property of Dispatch is max value. I am not supposed to do any changes in Modeling. So can we do any thing at reporting level to get the desired output?
Desired output---->0.001694
Output coming---->.0033120
Please help me in getting the desired output at query level.
Regards,solved with the help of nested exception aggregation
-
Change layout of Adhoc query output list for Custom infotype
Hi All,
The fields in the Infoset query output on a custom infotype are aligned with the fields u2018payment typeu2019 and u2018amountu2019 appearing repeatedly(in columns) as declared in the Infotype and the output will be a long horizontal list.
Instead, the requirement is that the output list should show vertically so that If I choose u2018Payment Typeu2019 and u2018Amountu2019 as output fields, it will show a long vertical list as in the case of a standard infotype (IT0008).
Also, this way enables user to use Payment Type as a selection criteria so as to just pulling the needed payment type. When we use IT0008 in the infoset it works fine but in custom IT it does not work.
Any pointers/suggestions on how we can achieve this would be helpful.Hi yu liang,
You can find vendor list having Vendor No. & without showing total liability for every vendor.
after executing the report,
1.You need to select "change layout (ctrl+F8)",
a small window comes, it has two part -> column content & hidden fields.
then u select "Vendor" from hidden field & move it to column content.
2. at column content there is a column named "Total". u need to remove check for your column name "amount".
now select "copy" button or enter. u will find the req. report.
u can save it also by ur name.
hope its helpful to u.......
plz, reward points as a way of thanks if helpful... -
To download the query output to falt file
Hi all,
i have a query which i know will give more than 65k records as the output for a selection.
i cannot run this query in excel due to its limitation.
if i run on web i cannot download this as downloading is happening to excel file only.
The customer ideally wants to download the query result to a text file(csv,tab-delimited etc) which inturn it will upload to MS-Access.
How do i achieve this?
SAP has given response use try using these options:
1.open interfaces to receive the output of a query via the MDX language.
2.open hub tool as it is designed for big amounts of data.(i suppose this is not possible as i want to download query output not the data target contents)
how do i achieve my scenario with option 1?
Are there any alternatives??
Any useful help will be rewarded.
Regards,
Dhanya.hi vivek,
thnks for the useful reply.
i have some problem with my ID,hence loggin in through my coleague's ID.
i will assign u points as i get logged in.
I did as u said by downloading it to unconverted format.
the file got download to a text file.where the output has
1.header rows(10 lines almost)
2.the values r coming in single quotes e,g:
'144000023073 'TAAS SETTLEMENT CONV 738 '19333000 '30.09.2006 '0.000
how can i remove all this?
Regards,
Dhanya
I -
How to get the Query output to Excel
Hi ,
Can you tell me how to get the Query output to excel with out using any third party tool?
Can you tell me how to write the code in Webservice and call it..
Please explain it Elaboartly..
Thanks in Advance!!!
Miniwhats your source system?
you can use Live office, or query as a webservice if you are getting data from universe
if you're getting data from SAP BI query and you have a java stack on your netweaver then you can get the data directly using sap bi connector in xcelsius.
good luck -
Query Output to download in flat file through APD or other means?
Hello Experts,
I am currently on BW3.5 system and have requirement to load query output in flat file in .csv format. I checked the option of APD but looks like we cant directly load the query output in flat file like in APD (BW 3.5 system) .
One way i can think of it...load the query output in transactional ODS and built an infospoke on it to write into flat file.
Please advice if there are any better methods to store the query output in flat files.
Thanks!Hi,
Use RSCRM_BAPI.
See
Re: RSCRM_Bapi
See the help on RSCRM_BAPI
Re: Running Quaries automatically and saving them in as a Excel file in Server
Re: Data transfer to external systems
Re: Loading from a Custom R/3 Table
Re: How can I schedule my Bex report to execute in background
Re: How can I insert the RSCRM_BAPI into Process chain?
Thanks
Reddy -
How to replace # or Not assigned with blank in BEx Query Output.
Hi,
While running the query through BEx Query desginer or Anlayser, I am getting # or Not assigned where there are no values.
The requirement is to "Replace # or Not assigned with a blank" in the output.
I want to know, is there any setting in BEx query desginer where we can do this. How to do this.
Please share your inputs on this. Any inputs on this would be appreciated.
Thanks,
NaveenCheck out SDN-thread: "Re: Remove 'Not assigned'" for more details
Ideas from SDN research:
"a solution i have used is to put each RKF column in a CKF colum then in each CKF use RKF + 0, the outcome is that your # should now be 0s, in the query properties you can set the option to display 0s as blank."
"try to enter a text for the blank entry in the master data maintenance of the relevant objects and set the display option for the objects to 'text'."
Threads:
SDN: How to replace # or Not assigned with blank in BEx Query Output.
SDN: Re: Remove 'Not assigned
SDN: How to replace # or (Not assigned) with blank in BEx Query Output.
SDN: Bex Analyzer : Text element system's table ?
SDN: change message in web application designer ["nonavailable" -> 136 of SAPLRRSV]
SDN: Not Assigned ["Not Assigned -> 027 of SAPLRRSV]
SDN: replacing '#'-sign for 'not assigned' in queries
SDN: # in report when null in the cube
SDN: How to replace '#' with blank when there is no value for a date field
Edited by: Thomas Köpp on Sep 13, 2010 5:20 PM -
How to store select query output in arrays.
i created a varray type variables and now want to assign some data though select query output in pl/sql code as well as in reports 6i.
You're in the wrong forum (this one is for issues with the SQL Developer tool). You were in the right one where you posted first, but don't reuse unrelated threads as you did.
Regards,
K. -
Output mismatch between BEx query output and WebI Report output
Hi All,
I have a BEx query in which there are only characteristics placed in rows.
There are combinations of the values of the characteristics giving different records in the query output.
Date is one of the characterisctics in the query output.
There is an output mismatch between the query output and the WebI report output in the following case:
When there are 'Not Assigned' or '#' or blank values, there are additional entries(rows) in the WebI report, giving repeating or wrong entries in the Date field. This is incorrect data.
Is this because of the 'Not Assigned' or '#' or blank values of the Characteristics or is there any other reason?
How do I fix this?
Please helo me with this.
Thanks and Regards,
Srilakshmi BHi Rajesh,
I need to verify the WebI report output for records with # and 'Not assigned' values for the cHracteristics in the report.
So I cannot check the WebI report by hiding the # or Not assigned values.
The problem is that in the Query output the records are like these shown below:
Char1 CHar2 CHar3 Date field
A B C Date1
#(Not assgined) #(Not assgined) #(Not assgined) No value
Where as the WebI report output is as below:
Char1 CHar2 CHar3 Date field
A B C Date1
#(Not assgined) #(Not assgined) #(Not assgined) Date1
As shown here, there are wrong/repeating entries for the Date field in the WebI report output.
Please check this and let me know what could be the issue and how do I fix it.
Thanks and Regards,
Srilakshmi B -
Query output transfer to excel file
hi all,
how can i query output transfer to excel file ? i am not using any tool. please suggest me. is there any method that i transfer that output to excel file?You can create a csv file. See dump_csv function from Tom Kyte.
-
Want to See Selected Input Variables in the query output
Hi al
My client gives a requirment like they want to see selected variables in the query output. Like suppose if i am entering Profit center, controlling area, version, caldayas a input on the screen. Now they want to see only Profit center and version on the query result.
Please let me know if any one has this solution.
Regards,
Amit ShetyeHi
Can you please give us user requirement and according to ure requirement so we given replies . If ure requirement please explain detail
But it is not neccessary that we can put something in free char and all. Inspite of that they wanted to select the input variable as per their requirement. They dont want to restrict them in Free char. -
Hello Experts,
Recently we have upgraded the system and we are facing issues with Ad-Hoc query output.
Issue : After entering data in selection fields and click on "OUTPUT" button we are getting output. now I changed the selection field data and click on "OUTPUT" button then we are getting message "No Data selected".
But when clicked on "HIT LIST" button for changed selection fields then we are getting HIT LIST count and after click of "OUTPUT" button we are getting output.
So at this point this is unclear why it is working after HIT LIST? This is not consistent but appearing most of the time.
Regards,
SaurabhThank you for reply. Yes I have checked SQ03, 02 and 01.
It is not specific to particular query it is appears to be for all the queries.
The important thing is to get the output we need to click first HIT LIST button and then OUTPUT. Is there any specific settings maintained for displaying output without clicking HIT LIST ?
Maybe you are looking for
-
Hi, Just got the 5800, loaded up some old pics and gifs, now when I go to open the gallery it loads all the pictures, then closes straight away, is there anyway round this ?
-
Hi All, In a production order there is an Overview for missing parts. It has information like committed quantity and committed date. We are looking for a standard SAP report that would give us this information by production order and material inste
-
Wrong pass word entred more than 10 times.
wrong pw entred by children= itouch diactivated how to restore it ?
-
IOS Group Messaging not working when Android phones are involved
Group Messaging not working for me when there are both Iphones and Androids involved. iPhones still using iOS 7 don't seem to be having problems leading me to believe this is an iOS 8 problem. Is there a workaround for this yet, or is this a legitima
-
I work for an elementary school and some of the teachers are getting new MacBook Pros with Mountain Lion on them. However, some of the programs they used to use with Snow Leopard are too old to be run on Mountain Lion. Is there a way to fix this and