Query Output Issues
Oracle: 10.2g
with my_tab as (select 99999 player_id, 'John Smith' player_name, 'Bulls' team_name, 16 points, 1 sequence from dual union all
select 99999 player_id, 'John Smith' player_name, 'Pistons' team_name, 4 points, 2 sequence from dual union all
select 55455 player_id, 'Bob Johnson' player_name, 'Rockets' team_name, 6 points, 1 sequence from dual union all
select 66489 player_id, 'Chris Terry' player_name, 'Kings' team_name, 2 points, 1 sequence from dual union all
select 99999 player_id, 'John Smith' player_name, 'Lakers' team_name, 8 points, 3 sequence from dual union all
select 66489 player_id, 'Chris Terry' player_name, 'Nuggets' team_name, 19 points, 2 sequence from dual union all
select 66777 player_id, 'Bob Terry' player_name, 'Spurs' team_name, 99 points, 1 sequence from dual union all
select 66331 player_id, 'Charles Smith' player_name, 'Jazz' team_name, 13 points, 1 sequence from dual)
select player_id,
player_name,
first_team_name,
sum(points) points,
||first_team_points
||' for '
||first_team_name
||
Total_Points
from (
select player_id,
player_name,
team_name,
points,
min(team_name) keep (
dense_rank first order by sequence
over
partition by player_id
first_team_name,
min(points) keep (
dense_rank first order by sequence
over
partition by player_id
first_team_points
from
my_tab
group by player_id,
player_name,
first_team_name,
||first_team_points
||' for '
||first_team_name
||
Current output:
1 66489 Chris Terry Kings 21 (2 for Kings)
2 99999 John Smith Bulls 28 (16 for Bulls)
3 55455 Bob Johnson Rockets 6 (6 for Rockets)
4 66777 Bob Terry Spurs 99 (99 for Spurs)
5 66331 Charles Smith Jazz 13 (13 for Jazz)
Desired Output:
1 66489 Chris Terry Nuggets 21 (2 for Kings)
2 99999 John Smith Lakers 28 (16 for Bulls, 4 for Pistons)
3 55455 Bob Johnson Rockets 6
4 66777 Bob Terry Spurs 99
5 66331 Charles Smith Jazz 13
Details:
- Sequence column is the sequence number of which team the player currently plays on, meaning the if a player was trade or switched teams like John Smith, the highest sequence is the players current team, so the Bulls was his first team, Piston 2nd, and Lakers current (since the highest sequence number)
-If a player changed teams (returns in more than one row of results) I would like:
A) current team listed as Team, so for John Smith above it should be Lakers
B) in perentesis, he should have his first team listed 1st along with point total scored on that team, 2nd team second w/point total and so on....
Like: John Smith Lakers 28(16 for Bulls, 4 for Pistons)
Not sure how to change my query around, thanks.
Edited by: user652714 on Mar 25, 2009 4:25 PM
Edited by: user652714 on Mar 25, 2009 5:06 PM
>
...but how do i go about concatenating the 'points' and 'total_points' columns. I tried to do something like...
>
something like this,
with my_tab as (select 99999 player_id, 'John Smith' player_name, 'Bulls' team_name, 16 points, 1 sequence from dual union all
select 99999 player_id, 'John Smith' player_name, 'Pistons' team_name, 4 points, 2 sequence from dual union all
select 55455 player_id, 'Bob Johnson' player_name, 'Rockets' team_name, 6 points, 1 sequence from dual union all
select 66489 player_id, 'Chris Terry' player_name, 'Kings' team_name, 2 points, 1 sequence from dual union all
select 99999 player_id, 'John Smith' player_name, 'Lakers' team_name, 8 points, 3 sequence from dual union all
select 66489 player_id, 'Chris Terry' player_name, 'Nuggets' team_name, 19 points, 2 sequence from dual union all
select 66777 player_id, 'Bob Terry' player_name, 'Spurs' team_name, 99 points, 1 sequence from dual union all
select 66331 player_id, 'Charles Smith' player_name, 'Jazz' team_name, 13 points, 1 sequence from dual)
SELECT player_id
, player_name
, Min(team_name) KEEP(DENSE_RANK First Order BY r_sequence) As team_name
, Sum(sum_points)||' '||Max(Case When r_sequence > 1 Then
'(' || REGEXP_REPLACE(SUBSTR(all_points,2),' ,[^,]$') || ')'
End) As total_points
FROM (SELECT player_id
, player_name
, team_name
, sequence
, Sum(points) As sum_points
, ROW_NUMBER() OVER(Partition BY player_id, player_name Order BY sequence Desc) As r_sequence
, STRAGG(' '||Sum(points)||' for '||team_name)OVER(Partition BY player_id,player_name Order BY sequence) As all_points
FROM my_tab
Group BY player_id
, player_name
, team_name
, sequence)
Group BY player_id
, player_name
Order BY Case When instr(total_points,'(') > 0 Then
regexp_replace(total_points,'([[:digit:]]+)[ (].*','\1')
End
, player_name;output
PLAYER_ID PLAYER_NAME TEAM_NAME TOTAL_POINTS
66489 Chris Terry Nuggets 21 (2 for Kings)
99999 John Smith Lakers 28 (16 for Bulls, 4 for Pistons)
55455 Bob Johnson Rockets 6
66777 Bob Terry Spurs 99
66331 Charles Smith Jazz 13Regards,
Christian Balz
Similar Messages
-
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 ? -
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
-
Issue with Saving the Query output data in Excel format
Hi,
Recnetly we had upgraded from 4.6c to ECC 6.0.
In ECc 6.0 environment, when user try to export the query output , we are getting only XML option to save the data.
But user want to save the data in EXcel format, he was able to do that in 4.6C.
pleas eprovide some inputs, on this issue.
Thanks,
Sanketh.I cannot for the life of me imagine, why a link to a post in the 'Business One Forum' where one uses ODBC to transfer query-data to MicroSoft Excel is of relevance to the OPs question, even if the same is not a security issue.
Never mind. [note 40155|https://service.sap.com/sap/support/notes/402155] deals with various symptoms in the ALV-Excel combination as as of release 4.6C. There are various others, mostly in components BC-SRV-ALV and BC-ABA-LI - also: I remember that when we upgraded from 4.5B to 4.7C there was an issue with Excel-templates -> the solution was in the release notes somewhere. So, in addition to SMP you might want to check the release notes and/or upgrade guide for solutions.
And yes, moderators ... this is not a security issue, this should go to ECC-Applications/Upgrade. -
hi there,
I have an issue with the display of hours 00:00:00 in the query output in BW.
The system assumes it as 0 or blank and therefore display it under unassigned hour.
I am using the reference of 0TIME for this hourly display.
When I checked the 0TIME i could not find the corresponding SID value for 00:00:00 hours.
Can anybody please advise what needs to be done?
Thanks in advance,
Kind regard,
KateHi Kate,
I am experiencing the same problem as you: an InfoObject, created referencing 0TIME, represented in the BEX Query as "#" when the Value is "00:00:00".
How did you work it out?
The Formula Variable strategy is not applicable in this case because 0TIME is not a key figure !
Bye
Aldo -
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 -
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 -
Appearing Duplicate column in ABAP QUERY output list.
Hi ,
I have created a report using SAP QUERY having issue on output display showing duplicate columns name Weight Unit (LIKP-GEWEI ) and rest of field area coming fine .
Kindly help to solve the issue .
Thanks .Hi,
The currency and quantity units get automatically displayed based on the currency and quantity fields on the output list. However you can restrict it by selecting those fields and choose No currency fields before or after and apply.
How to do?
1. Goto SQ01, provide your query name and select "Infoset Query".
2. Now choose the currency/quantity fields on the lower bottom of window.
3. Right click on the field and traverse to Unit->Do not Output.
Hope this helps!
Br,
Maju -
BEX iView - Remove unwanted tabs in the query output
Hi
EP SP 6.0 SP21
BW 3.5
We have created a couple of BEX iViews that reported from the BW system. But we do not want some of the options provided by the BEX iView like the sorts, characteristics, etc and wanted to hide the query tabs that we are not using like informaiton broadcasting etc.
Has any one been succesful in removing this unwanted options from the BEX query output? I couldn't find anything in the iView properties that helped me with the issue.
Appreciate any suggestion on this item.
regards
RajHi Raj,
I suggest you to have a webtemplate against the query and create SAP BW Report iVew in the portal.
Iin WAD tool you suppress standard options/ have new options by adding javascript & Html code.
Ram -
Result Row in the query output
Hi,
If I restrict a characteristic by hierarchy then I cant have the result row displayed. If the hierarchy active is removed then the result row gets displayed. All characteristics are marked to show the result row.
This characteristic is Account Number. If in the query definition I remove the restriction on account numbers and just select hierarchy active and the required hierarchy in the properties then I get the result row in the output. But now it also displays all the unassigned account numbers in a separate node Not Assigned Account Number (s).
I cant even restrict it in the output with hierarchy active selected. When I do select filter value in the output the options Include in Selection and exclude from Selection are grayed out and hence cant select it.
Please advice on this issue
Thank you,
samHi Jaya,
I think you misunderstood my issue.
My problem is not that i do not want to see the field. But instead, i do not want to see only the results row in the query output.
I need to have the results to populate a calculation via sumct formula.
My question is, can sumct be populated if i hide/supress RESULT row ?
Regards,
Maili -
WRITEQUERY program output issue..
hi,
we are using writequery program for one of our apps. when using writequery prg. the description is not displalyed completly in the output, but displays properly in BEx query output. Any thoughts on this issue..we have to use writequery for our app..
thanksHi,
Create a Background job schedule it will runs in background automatically it will creates a spool.
To Create Background job schedule T-Code SM36
To Execute the Background job schedule T-code SM37
To see the spool T-code is SP01.
Thanks
Ganesh -
Transfer SAP Query Output directly to SharePoint
Hi,
We are running the SAP Queries in the Background. I have a requirement to transfer the SAP Query output directly to SharePoint site. Could you please share your ideas on this?
Regards,
Siva.I don't have an answer but have the same issue. Did you ever resolve?
-
Oracle Query output erro (MX7)
Hi
Coldfusion page throwing ODBC error when Oracle (9i) Query
executed. No useful error message shown.
Same query gets executed successfully in Oracle Client.
When i use CLOB Column type in my select query error has
shown. In the same query i have used substr anticipating that some
issues when oracle column type being being CLOB in coldfushion
page. It did not work.
Query output returns some html tags also. I guess we need to
set some configurations in Coldfusion server. As the same code runs
perfectly on the test/production environment.
Pointers are highly appreicated.
Regards
Ram
Beginner in coldfusion Technologysince you didn't show the query, or the error message, I'll
just take a guess and say that you ended your sql with a
semi-colon. -
Modifying the text "Result" and "Overall Result" in a BEx query output
Hi,
1) Is it possible to modify the text "Result", "Overall Result" which appears in the sub-total and grand total lines of BEx query output? I do not see any related setting the properties area of the object in BEx Query designer. Do I have to write some VB code or can I do something in Customer Exits?
Also my client wants that this text need to be made dynamic such as "Sub-Total for the month of Jan 2006".
I can use work book option and change the texts manually.But this is not meeting my clients requirement.
2)Is it possible to have dynamic title text for a BEx query?
We are on BW 3.5 & if any of you could provide / guidance to the above issue.
Thanks,
VenkatramYou will have to use VB Macros to change the text "Result" and "Overall Result", there is not settings in the query designer for the same.
You can have dynamic descriptions for queries using text variables like Expense Query for month of Jan 2006, if user selected Jan 2006.
Thanks.
Maybe you are looking for
-
Unable to install JRun on Linux receive error while loading shared libraries
I'm installing JRun trial version on Ubuntu with java version "1.6.0_07". I receive the following errors when I install: guest:~/Desktop$ sh ./jrun-40-linux-en.bin -i gui Preparing to install... Extracting the installation resources from the installe
-
I am currently in Brazil and have bought a sim for my phone whilst over here, but the language as changed to portugese, is there anyway I can change it bck to English?
-
I can get Safari to enlarge font sizes but suddenly, today, it stopped enlarging images. I used to be able to hit Control+ and Safari would enlarge the image. Today, it stopped doing it. Any suggestions? Thank you.
-
What does Match do to Apple Lossless and AIFF?
I have all my music imported as Apple Lossless. Will I lose quality if I use Match? Thanks, Ken
-
If I want to forward an email with an attachment (data charges?)
Hi all, I wonder if anyone can help. I currently have a BlackBerry and use it all the time. I would like to move over to a iPhone as it is far superior at viewing attachements but there is one thing that is stopping me and I would like to know if the