Selecting first 15 rows and displaying next 15
I wish to select the first 15 rows from my database and then have an option select a next page, whereby the next 15 rows are displayed. I'm not sure how to go about it, could someone enlighten me. For reference, it would be something like how the forums is done, whereby they display x amount of threads, and you would have to go to the next page.
This can be done by retrieving the first 15 using something like rownum <= 15 in the where clause.
Then, by remembering the ID of the last thread that was displayed you select threads id > lastID and rownum <= 15... that is the first 15 rows that match your query starting immediately after the last thread searched.
It's not unusual to retrieve and store a list of the Thread IDs completely as this allows a more stable feedback at the expense of heavier session information being stored.
Hope that helps
Talden
Similar Messages
-
Select 4 rows and then next 4 rows
in my sql we can use limit to select first 4 rows in the table then next 4 rows ,
can oracle do that ?
I have fifty rows inside the table
select * from student where rownum between 0 and 4 order by stuid ->it work
select * from student where rownum between 5 and 9 order by stuid -> did not work
what is the correct way to do it ?knksoft wrote:
thanks jeneesh and frank, i got it.
SELECT * FROM
SELECT A.*,ROWNUM RN FROM EMP A order by emp_id
) WHERE RN <=5 AND RN>=3this should be correct i think. so why we need to use analytical function for this?. somewhere in this forum i read analytical functions will be less performance than normal sql.It wont be correct...Coz, rownum is generated before ORDER BY. So your rownum will not be actually in sequence..
SQL> select ename,rownum
2 from emp
3 order by ename;
ENAME ROWNUM
ADAMS 11
ALLEN 2
BLAKE 6
CLARK 7
FORD 13
JAMES 12
JONES 4
KING 9
MARTIN 5
MILLER 14
SCOTT 8
SMITH 1
TURNER 10
WARD 3
14 rows selected.Analytics is the best way, or
select *
from
SELECT b.*,rownum rn
FROM
SELECT A.*
FROM EMP A
order by emp_id
) b
WHERE RN <=5 AND RN>=3 -
Select most recent file and display
I've been considerig this and I am closer to how I expect it to work
This is what I have so far but can't peice together just yet.
Get the current open folder window look for the last item if shot within the last 30 secs of the creation date, if shot within 30 secs then select/highlight the file and use system events to press keystroke y using cmd and option down.(to put it on the screen in full screen) Display for 15 secs, or if esc hit then wait for next file to arrive and so on.
If the window is closed of the current open folder then end applescript.
This is how far I have got but can't link the ideas together well.
set theWindow to name of front window of application "Finder"
set theWindow to name of front window of application "Finder"
set theFldr to path of theWindow
tell application "Finder"
set theContents to sort items of theFldr by creation date
set theLastimage to (contents of item 1 of theContents) as text
--is it within the last 30 seconds?
-- yes, then
tell application "System Events"
keystroke "y" using {command down, option down}
delay 15
key code 53
--then wait for arrival of next image. and repeat.
--if theWindow is close end applescript.
end tell
end tellHi,
If you don't want to use a folder action, try this :
try
tell application "Finder" to set currFolder to name of front Finder window
on error
return -- no Finder window
end try
set tDate to (current date) - 30
repeat
set b to false
tell application "Finder"
set fWindows to Finder windows whose it's name is currFolder
if (fWindows is not {}) then
set tWind to item 1 of fWindows
set nFiles to document files of tWind whose creation date > tDate -- get newer files
set tDate to (current date)
if nFiles is not {} then
reveal nFiles
my selectionfullScreen(currFolder, count nFiles)
set b to true
end if
else
exit repeat -- quit the script, the current Folder is closed
end if
end tell
if not b then delay 5 -- no recent files, wait 5 seconds
end repeat
on selectionfullScreen(tName, n)
tell application "System Events"
tell process "Finder"
set frontmost to true
keystroke "y" using {command down, option down}
repeat (15 * n) times
tell window 1 to if (exists) and (its title is tName) then return -- the user close QuickLook
delay 1
end repeat
tell window 1 to if (exists) and (its title is not tName) then key code 53 -- close QuickLook after (15 seconds X (number of images))
end tell
end tell
end selectionfullScreen -
Select First 10 rows of data based on dates
Hi,
Have a report like this
"Object Name", "Object Type", "Complexity", "Task Name", "RCCL Close Date"
ABC XXX MEDIUM Design 1-1-2008
BBC XXX MEDIUM Design 2-1-2008
ABC XXX MEDIUM Design 3-1-2008
BBC XXX MEDIUM Design 4-1-2008
ABC XXX MEDIUM Design 5-1-2008
BBC XXX MEDIUM Design 6-1-2008
ABC XXX MEDIUM Design 7-1-2008
BBC XXX MEDIUM Design 8-1-2008
ABC XXX MEDIUM Design 9-1-2008
BBC XXX MEDIUM Design 10-1-2008
ABC XXX MEDIUM Design 11-1-2008
BBC XXX MEDIUM Design 12-1-2008
ABC XXX MEDIUM Design 13-1-2008
BBC XXX MEDIUM Design 14-1-2008
ABC XXX MEDIUM Design 15-1-2008
BBC XXX MEDIUM Design 16-1-2008
How to select the first 10 rows using a sql query please suggest me..
Thanks
Sudhir.I tryed your code but this is returning only the 10th row data not all 10 rows data please suggest me how to modify the code
The code below is wht i am using to execute. when i put a condition rno >= 10 it is showing me the 10th row data.
only single row. please suggest me in modifying the code
select
from
select
"Project Name",
"Object Name",
"Object Type",
"Complexity",
"Task Name",
"Actual Effort",
"Plan Effort",
"Close Date",
--count(*) over (partition by "Object Name" order by "Close Date" ) recs
row_number() over(order by "Close Date") rno
from
SELECT
"Project Name",
"Object Name",
"Object Type",
"Complexity",
MAX("Task Name") "Task Name",
SUM("Actual Effort") "Actual Effort",
SUM("Plan Effort") "Plan Effort",
MAX("Close Date") "Close Date"
FROM
SELECT
"Project Name",
"Object Name",
"Object Type",
"Complexity",
MAX("Task Name") "Task Name",
SUM("Actual Effort") "Actual Effort",
SUM("Plan Effort") "Plan Effort",
SUM("EV") "EV",
MAX("Close Date") "Close Date"
FROM
SELECT
INITCAP(pro.project_name) "Project Name",
INITCAP(pobj.name) "Object Name",
INITCAP(POBJ.PROGRAM_TYPE) "Object Type",
INITCAP(POBJ.COMPLEXITY) "Complexity",
INITCAP(tas.name) "Task Name",
SUM( nvl(TCL.NUM_HOURS_DAY1,0) + nvl(TCL.NUM_HOURS_DAY2,0) +
nvl(TCL.NUM_HOURS_DAY3,0) + nvl(TCL.NUM_HOURS_DAY4,0) +
nvl(TCL.NUM_HOURS_DAY5,0) + nvl(TCL.NUM_HOURS_DAY6,0) +
nvl(TCL.NUM_HOURS_DAY7,0) ) "Actual Effort",
CASE
WHEN upper(:P68_TASK) LIKE UPPER('Incomming-Doc Review') Then SR.INCOMMING_DOC
WHEN upper(:P68_TASK) LIKE UPPER('Design') Then
SR.DESIGN
WHEN upper(:P68_TASK) LIKE UPPER('Design Review') Then
SR.DESIGN_REVIEW
WHEN upper(:P68_TASK) LIKE UPPER('Design Rework') Then
SR.DESIGN_REWORK
WHEN upper(:P68_TASK) LIKE UPPER('Build') Then
SR.BUILD
WHEN upper(:P68_TASK) LIKE UPPER('Build Review') Then
SR.BUILD_REVIEW
WHEN upper(:P68_TASK) LIKE UPPER('Build Rework') Then
SR.BUILD_REWORK
WHEN :P68_TASK in ('Test Plan Prep','Unit Test Plan') Then
SR.TEST_CASE_PREP
WHEN :P68_TASK in ('Test Plan Review','Unit Test Plan Review') Then
SR.TEST_CASE_REVIEW
WHEN :P68_TASK in ('Test Plan Rework','Unit Test Plan Rework') Then
SR.TEST_CASE_REWORK
WHEN :P68_TASK in ('Testing','Unit Testing') Then
SR.UNIT_TESTING
WHEN :P68_TASK in ('Test Result Review','Unit Test Result Review') Then
SR.TEST_RESULT_REVIEW
WHEN upper(:P68_TASK) LIKE UPPER('Installation Review') Then
SR.INSTALLATION_SCRIPT
WHEN upper(:P68_TASK) LIKE UPPER('Release-Review') Then
SR.RELEASE_REVIEW
WHEN upper(:P68_TASK) LIKE UPPER('FDD Review') Then
SR.FDD_REVIEW
End "Plan Effort",
CASE
WHEN upper(:P68_TASK) LIKE UPPER('Incomming-Doc Review') Then
trunc((((
SUM( nvl(TCL.NUM_HOURS_DAY1,0) + nvl(TCL.NUM_HOURS_DAY2,0) +
nvl(TCL.NUM_HOURS_DAY3,0) + nvl(TCL.NUM_HOURS_DAY4,0) +
nvl(TCL.NUM_HOURS_DAY5,0) + nvl(TCL.NUM_HOURS_DAY6,0) +
nvl(TCL.NUM_HOURS_DAY7,0) )
nvl(SR.INCOMMING_DOC,0)
) / decode(SR.INCOMMING_DOC,0,null,SR.INCOMMING_DOC) ) * 100 ),2)
WHEN upper(:P68_TASK) LIKE UPPER('Design') Then
trunc((((
SUM( nvl(TCL.NUM_HOURS_DAY1,0) + nvl(TCL.NUM_HOURS_DAY2,0) +
nvl(TCL.NUM_HOURS_DAY3,0) + nvl(TCL.NUM_HOURS_DAY4,0) +
nvl(TCL.NUM_HOURS_DAY5,0) + nvl(TCL.NUM_HOURS_DAY6,0) +
nvl(TCL.NUM_HOURS_DAY7,0) )
nvl(SR.DESIGN,0)
) / decode(SR.DESIGN,0,null,SR.DESIGN) ) * 100 ),2)
WHEN upper(:P68_TASK) LIKE UPPER('Design Review') Then
trunc((((
SUM( nvl(TCL.NUM_HOURS_DAY1,0) + nvl(TCL.NUM_HOURS_DAY2,0) +
nvl(TCL.NUM_HOURS_DAY3,0) + nvl(TCL.NUM_HOURS_DAY4,0) +
nvl(TCL.NUM_HOURS_DAY5,0) + nvl(TCL.NUM_HOURS_DAY6,0) +
nvl(TCL.NUM_HOURS_DAY7,0) )
nvl(SR.DESIGN_REVIEW,0)
) / decode(SR.DESIGN_REVIEW,0,null,SR.DESIGN_REVIEW) ) * 100 ),2)
WHEN upper(:P68_TASK) LIKE UPPER('Design Rework') Then
trunc((((
SUM( nvl(TCL.NUM_HOURS_DAY1,0) + nvl(TCL.NUM_HOURS_DAY2,0) +
nvl(TCL.NUM_HOURS_DAY3,0) + nvl(TCL.NUM_HOURS_DAY4,0) +
nvl(TCL.NUM_HOURS_DAY5,0) + nvl(TCL.NUM_HOURS_DAY6,0) +
nvl(TCL.NUM_HOURS_DAY7,0) )
nvl(SR.DESIGN_REWORK,0)
) / decode(SR.DESIGN_REWORK,0,null,SR.DESIGN_REWORK) ) * 100 ),2)
WHEN upper(:P68_TASK) LIKE UPPER('Build') Then
trunc((((
SUM( nvl(TCL.NUM_HOURS_DAY1,0) + nvl(TCL.NUM_HOURS_DAY2,0) +
nvl(TCL.NUM_HOURS_DAY3,0) + nvl(TCL.NUM_HOURS_DAY4,0) +
nvl(TCL.NUM_HOURS_DAY5,0) + nvl(TCL.NUM_HOURS_DAY6,0) +
nvl(TCL.NUM_HOURS_DAY7,0) )
nvl(SR.BUILD,0)
) / decode(SR.BUILD,0,null,SR.BUILD) ) * 100 ),2)
WHEN upper(:P68_TASK) LIKE UPPER('Build Review') Then
trunc((((
SUM( nvl(TCL.NUM_HOURS_DAY1,0) + nvl(TCL.NUM_HOURS_DAY2,0) +
nvl(TCL.NUM_HOURS_DAY3,0) + nvl(TCL.NUM_HOURS_DAY4,0) +
nvl(TCL.NUM_HOURS_DAY5,0) + nvl(TCL.NUM_HOURS_DAY6,0) +
nvl(TCL.NUM_HOURS_DAY7,0) )
nvl(SR.BUILD_REVIEW,0)
) / decode(SR.BUILD_REVIEW,0,null,SR.BUILD_REVIEW) ) * 100 ),2)
WHEN upper(:P68_TASK) LIKE UPPER('Build Rework') Then
trunc((((
SUM( nvl(TCL.NUM_HOURS_DAY1,0) + nvl(TCL.NUM_HOURS_DAY2,0) +
nvl(TCL.NUM_HOURS_DAY3,0) + nvl(TCL.NUM_HOURS_DAY4,0) +
nvl(TCL.NUM_HOURS_DAY5,0) + nvl(TCL.NUM_HOURS_DAY6,0) +
nvl(TCL.NUM_HOURS_DAY7,0) )
nvl(SR.BUILD_REWORK,0)
) / decode(SR.BUILD_REWORK,0,null,SR.BUILD_REWORK) ) * 100 ),2)
WHEN :P68_TASK in ('Test Plan Prep','Unit Test Plan') Then
trunc((((
SUM( nvl(TCL.NUM_HOURS_DAY1,0) + nvl(TCL.NUM_HOURS_DAY2,0) +
nvl(TCL.NUM_HOURS_DAY3,0) + nvl(TCL.NUM_HOURS_DAY4,0) +
nvl(TCL.NUM_HOURS_DAY5,0) + nvl(TCL.NUM_HOURS_DAY6,0) +
nvl(TCL.NUM_HOURS_DAY7,0) )
nvl(SR.TEST_CASE_PREP,0)
) / decode(SR.TEST_CASE_PREP,0,null,SR.TEST_CASE_PREP) ) * 100 ),2)
WHEN :P68_TASK in ('Test Plan Review','Unit Test Plan Review') Then
trunc((((
SUM( nvl(TCL.NUM_HOURS_DAY1,0) + nvl(TCL.NUM_HOURS_DAY2,0) +
nvl(TCL.NUM_HOURS_DAY3,0) + nvl(TCL.NUM_HOURS_DAY4,0) +
nvl(TCL.NUM_HOURS_DAY5,0) + nvl(TCL.NUM_HOURS_DAY6,0) +
nvl(TCL.NUM_HOURS_DAY7,0) )
nvl(SR.TEST_CASE_REVIEW,0)
) / decode(SR.TEST_CASE_REVIEW,0,null,SR.TEST_CASE_REVIEW) ) * 100 ),2)
WHEN :P68_TASK in ('Test Plan Rework','Unit Test Plan Rework') Then
trunc((((
SUM( nvl(TCL.NUM_HOURS_DAY1,0) + nvl(TCL.NUM_HOURS_DAY2,0) +
nvl(TCL.NUM_HOURS_DAY3,0) + nvl(TCL.NUM_HOURS_DAY4,0) +
nvl(TCL.NUM_HOURS_DAY5,0) + nvl(TCL.NUM_HOURS_DAY6,0) +
nvl(TCL.NUM_HOURS_DAY7,0) )
nvl(SR.TEST_CASE_REVIEW,0)
) / decode(SR.TEST_CASE_REWORK,0,null,SR.TEST_CASE_REWORK) ) * 100 ),2)
WHEN :P68_TASK in ('Testing','Unit Testing') Then
trunc((((
SUM( nvl(TCL.NUM_HOURS_DAY1,0) + nvl(TCL.NUM_HOURS_DAY2,0) +
nvl(TCL.NUM_HOURS_DAY3,0) + nvl(TCL.NUM_HOURS_DAY4,0) +
nvl(TCL.NUM_HOURS_DAY5,0) + nvl(TCL.NUM_HOURS_DAY6,0) +
nvl(TCL.NUM_HOURS_DAY7,0) )
nvl(SR.UNIT_TESTING,0)
) / decode(SR.UNIT_TESTING,0,null,SR.UNIT_TESTING) ) * 100 ),2)
WHEN :P68_TASK in ('Test Result Review','Unit Test Result Review') Then
trunc((((
SUM( nvl(TCL.NUM_HOURS_DAY1,0) + nvl(TCL.NUM_HOURS_DAY2,0) +
nvl(TCL.NUM_HOURS_DAY3,0) + nvl(TCL.NUM_HOURS_DAY4,0) +
nvl(TCL.NUM_HOURS_DAY5,0) + nvl(TCL.NUM_HOURS_DAY6,0) +
nvl(TCL.NUM_HOURS_DAY7,0) )
nvl(SR.TEST_RESULT_REVIEW,0)
) / decode(SR.TEST_RESULT_REVIEW,0,null,SR.TEST_RESULT_REVIEW) ) * 100 ),2)
WHEN upper(:P68_TASK) LIKE UPPER('Installation Review') Then
trunc((((
SUM( nvl(TCL.NUM_HOURS_DAY1,0) + nvl(TCL.NUM_HOURS_DAY2,0) +
nvl(TCL.NUM_HOURS_DAY3,0) + nvl(TCL.NUM_HOURS_DAY4,0) +
nvl(TCL.NUM_HOURS_DAY5,0) + nvl(TCL.NUM_HOURS_DAY6,0) +
nvl(TCL.NUM_HOURS_DAY7,0) )
nvl(SR.INSTALLATION_SCRIPT,0)
) / decode(SR.INSTALLATION_SCRIPT,0,null,SR.INSTALLATION_SCRIPT) ) * 100 ),2)
WHEN upper(:P68_TASK) LIKE UPPER('Release-Review') Then
trunc((((
SUM( nvl(TCL.NUM_HOURS_DAY1,0) + nvl(TCL.NUM_HOURS_DAY2,0) +
nvl(TCL.NUM_HOURS_DAY3,0) + nvl(TCL.NUM_HOURS_DAY4,0) +
nvl(TCL.NUM_HOURS_DAY5,0) + nvl(TCL.NUM_HOURS_DAY6,0) +
nvl(TCL.NUM_HOURS_DAY7,0) )
nvl(SR.RELEASE_REVIEW,0)
) / decode(SR.RELEASE_REVIEW,0,null,SR.RELEASE_REVIEW) ) * 100 ),2)
WHEN upper(:P68_TASK) LIKE UPPER('FDD Review') Then
trunc((((
SUM( nvl(TCL.NUM_HOURS_DAY1,0) + nvl(TCL.NUM_HOURS_DAY2,0) +
nvl(TCL.NUM_HOURS_DAY3,0) + nvl(TCL.NUM_HOURS_DAY4,0) +
nvl(TCL.NUM_HOURS_DAY5,0) + nvl(TCL.NUM_HOURS_DAY6,0) +
nvl(TCL.NUM_HOURS_DAY7,0) )
nvl(SR.FDD_REVIEW,0)
) / decode(SR.FDD_REVIEW,0,null,SR.FDD_REVIEW) ) * 100 ),2)
End "EV",
NULL "Close Date"
FROM
timecard_lines tcl,
project_objects pobj,
tasks tas,
projects pro,
timecard_headers thr,
TIMECARD_PERIODS TP,
Sub_Proc_Replan SR
WHERE
pro.id = :P1_PROJECTS AND
TP.ID = THR.TPD_ID AND
tcl.pobj_id = pobj.id AND
tcl.tas_id = tas.id AND
pro.id = pobj.pro_id AND
thr.id = tcl.thr_id AND
pobj.id = tcl.pobj_id and
PRO.ID = SR.PRO_ID AND
POBJ.ID = SR.POBJ_ID AND
upper(tas.name) like upper(:P68_TASK)
and tas.name not in ('Wait Time','Wait time','Wait-Time','Project Management',
'Quality Management','Offshore-Onsite','Wait_Time')
and pobj.id in
(SELECT distinct pobj.id
FROM
task_status ts,projects pro,project_objects pobj,task tsk
,employees emp,employee_project_pairs epp,REVIEW_ITEMS RI
WHERE
pro.id = :p1_projects and
pobj.pro_id = pro.id
and pro.id = ts.pro_id
and pobj.id = ts.pro_obj_id
and tsk.id = ts.task_id
and emp.id = epp.emp_id
and epp.pro_id = pro.id
and ts.id = ri.ts_id
and tsk.name in
('Incomming-Doc Review',
'Incoming Doc- Review',
'Incoming Doc- Review',
'FDD - Review',
'Architecture - Review',
'Design Review',
'Design - Review',
'TDD - Review',
'Build Review',
'Build - Review',
'Code - Review',
'Code',
'Test Result Review',
'Test Result - Review',
'UTR - Review',
'Test - Review',
'Installation Review',
'Installation - Review',
'Release-Review',
'Release - Verification',
'Migration & Release - Review',
'Release - Review')
and ts.status in ('CLOSE','ACCEPTED','closed')
and ( upper(:P68_TASK) like '%'||upper(substr(tsk.name,1,5))||'%'
or upper(:P68_TASK_NAMES) like '%'||upper(substr(tsk.name,1,5))||'%' )
GROUP BY
pro.project_name,pobj.name,tas.name,POBJ.PROGRAM_TYPE,POBJ.COMPLEXITY,SR."Effort",SR.INCOMMING_DOC,SR.DESIGN,SR.DESIGN_REVIEW,SR.DESIGN_REWORK,SR.BUILD,
SR.BUILD_REVIEW,SR.BUILD_REWORK,SR.TEST_CASE_PREP,SR.TEST_CASE_REVIEW,
SR.TEST_CASE_REWORK,SR.UNIT_TESTING,SR.TEST_RESULT_REVIEW,
SR.INSTALLATION_SCRIPT,SR.RELEASE_REVIEW,SR.FDD_REVIEW
UNION
SELECT distinct
INITCAP(pro.project_name) "Project Name",
INITCAP(pobj.name) "Object Name",
INITCAP(POBJ.PROGRAM_TYPE) "Object Type",
INITCAP(POBJ.COMPLEXITY) "Complexity",
NULL "Task Name",
NULL "Actual Effort",
NULL "Plan Effort",
NULL "EV",
decode(
MAX(ts.close_timestamp),null,
MAX(ts.REVIEWER_ACCEPTED_DATE),
MAX(ts.close_timestamp) ) "Close Date"
FROM
task_status ts,projects pro,project_objects pobj,task tsk
,employees emp,employee_project_pairs epp,REVIEW_ITEMS RI
WHERE
pro.id = :p1_projects and
pobj.pro_id = pro.id
and pro.id = ts.pro_id
and pobj.id = ts.pro_obj_id
and tsk.id = ts.task_id
and emp.id = epp.emp_id
and epp.pro_id = pro.id
and ts.id = ri.ts_id
and tsk.name in
('Incomming-Doc Review',
'Incoming Doc- Review',
'Incoming Doc- Review',
'FDD - Review',
'Architecture - Review',
'Design Review',
'Design - Review',
'TDD - Review',
'Build Review',
'Build - Review',
'Code - Review',
'Code',
'Test Result Review',
'Test Result - Review',
'UTR - Review',
'Test - Review',
'Installation Review',
'Installation - Review',
'Release-Review',
'Release - Verification',
'Migration & Release - Review',
'Release - Review')
and ts.status in ('CLOSE','ACCEPTED','closed')
and ( upper(:P68_TASK) like '%'||upper(substr(tsk.name,1,5))||'%'
or upper(:P68_TASK_NAMES) like '%'||upper(substr(tsk.name,1,5))||'%' )
group by pro.project_name,pobj.name,tsk.name,POBJ.PROGRAM_TYPE,pobj.complexity
GROUP BY "Project Name","Object Name", "Object Type", "Complexity"
WHERE "Task Name" IS NOT NULL
GROUP BY "Project Name","Object Name", "Object Type", "Complexity"
order by "Close Date"
where rno >= 10
and rownum <= 10
Thanks
Sudhir -
Select Date between range and display
Hello - i need some ideas to the following:
I need to create a form to submit some information, with the
date that form was submitted, to a database using php.
Once the form is submitted i need to retrieve multiple rows
from the database based on a selected date range, and display the
information
Question one - any ideas on the flow that i need
question two - how do you think that i best record the date -
given that i need to select a range later.
question three - how do I select mutiple rows give a range of
dates
ThanksHello - i need some ideas to the following:
I need to create a form to submit some information, with the
date that form was submitted, to a database using php.
Once the form is submitted i need to retrieve multiple rows
from the database based on a selected date range, and display the
information
Question one - any ideas on the flow that i need
question two - how do you think that i best record the date -
given that i need to select a range later.
question three - how do I select mutiple rows give a range of
dates
Thanks -
BI-IP - Bex Analyser - select excel single row and aplly planning function
Hi experts,
In BI-IP (BW 7) with Bex Analyser, is it possible to select a single excel row (or a range of rows) and then apply a planning function? I know that in WAD it's possible with the binding option to select a single web item.
The purpose is to apply a revaluation factor to selected (by the user) cost elements rows in the workbook.
Thanks and regards,
MAHi
It is possibel in WAD to select one or many rows while executing Functions such as--Reposting; Revaluation etc.
However, you should be in a position to select the rows based on....unique identifier such as Require ID; Request #; Serial #; ....this is more so in case of multiple entries for the same cost element for different combinations.
Regards
Srinivas -
Need help to count number of rows and display in file
Hello,
my scenario is IDOC to File......i am using XSLT mapping and using FCC parameters to convert the flat file.
now new requirement is i need to count number of rows and add count value last of the file.
Please let me know how to do it,
thanks in advance for your help.
Regards,
Chinnathanks again, one more Q.
in XSLT mapping i have written for loop for complete structure.
example : <Details>
<node1>
<node2>
</details>
in XSLT mapping
<xsl:for-each select="ZMATMAS_01/IDOC/E1MARAM">
<Details>
</Details>
</xsl:for-each>
if i add the field at target side....then i will come under details node and it will be repeated.
how to declare in XSLT mapping. -
Dynamic Select Options/Ranges Maintain and Display in my screen
Hi I am trying to figure out if I can create a screen which will will read various select-options I have stored in a custom table but am having trouble finding something which will allow me to display each of 'select-options' in my dynpro... has anyone ever done this?
I'd rather not reinvent the wheel or mimic - does anyone know of a way to basically use a loaded range and display it on a screen for display or maintenance using standard SAP routines/classes?
Thanks in advance!
Roc..@Adrian - I got your email regarding the code sample, here is a quick example of how to popup a dynamic selection for up to 5 tables...
*& Report ZRS_DYNAMIC
REPORT zrs_dynamic.
* START Dynamic Range Selection Definitions
* Definition of the selection_if variable, which is used to reference
* the selections obtained
DATA: gv_selid TYPE rsdynsel-selid.
* Definition of the TABLES_TAB table for use in providing the list of
* fields available for creating select options from
DATA: gt_tables TYPE STANDARD TABLE OF rsdstabs.
DATA: gs_tables TYPE rsdstabs.
PARAMETERS: p_tab1 TYPE tabname DEFAULT 'KNA1',
p_tab2 TYPE tabname DEFAULT 'KNB1',
p_tab3 TYPE tabname DEFAULT 'KNC1',
p_tab4 TYPE tabname DEFAULT 'KNVV',
p_tab5 TYPE tabname DEFAULT 'KNVP'.
START-OF-SELECTION.
gs_tables-prim_tab = p_tab1 .APPEND gs_tables TO gt_tables.
gs_tables-prim_tab = p_tab2 .APPEND gs_tables TO gt_tables.
gs_tables-prim_tab = p_tab3 .APPEND gs_tables TO gt_tables.
gs_tables-prim_tab = p_tab4 .APPEND gs_tables TO gt_tables.
gs_tables-prim_tab = p_tab5 .APPEND gs_tables TO gt_tables.
* Definition of Table which includes the select-option range for field
TYPES: ty_selopt_t TYPE rsdsselopt OCCURS 10.
* Definition of field name and select option range table
TYPES: BEGIN OF ty_frange,
fieldname TYPE rsdstabs-prim_fname,
selopt_t TYPE ty_selopt_t,
END OF ty_frange.
TYPES: ty_frange_t TYPE ty_frange OCCURS 10.
TYPES: BEGIN OF ty_range,
tablename LIKE rsdstabs-prim_tab,
frange_t TYPE ty_frange_t,
END OF ty_range.
TYPES: ty_range_t TYPE STANDARD TABLE OF ty_range.
DATA: it_ranges TYPE ty_range_t.
* work areas
DATA: gs_ranges TYPE ty_range.
DATA: gs_frange TYPE ty_frange.
DATA: gs_selopt TYPE rsdsselopt.
DATA: gt_ranges TYPE ty_range_t.
DATA: gt_frange TYPE ty_frange_t.
DATA: gt_selopt TYPE ty_selopt_t.
* Definition of the fields list avaiable
TYPES: ty_fields TYPE STANDARD TABLE OF rsdsfields.
DATA: it_fields TYPE ty_fields.
DATA: gs_fields TYPE rsdsfields.
* END Dynamic Range Selection --------------------------------------------
CALL FUNCTION 'FREE_SELECTIONS_INIT'
EXPORTING
kind = 'T'
IMPORTING
selection_id = gv_selid
TABLES
tables_tab = gt_tables.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'FREE_SELECTIONS_DIALOG'
EXPORTING
selection_id = gv_selid
title = 'Select WHERE criteria for Rule'(s12)
as_window = 'X'
start_row = 7
start_col = 10
IMPORTING
field_ranges = it_ranges
TABLES
fields_tab = it_fields
EXCEPTIONS
internal_error = 1
no_action = 2
selid_not_found = 3
illegal_status = 4
OTHERS = 5.
Edited by: Rocco Scocco on Jun 17, 2010 3:48 PM
Edited by: Rocco Scocco on Jun 17, 2010 3:49 PM -
Supress Subtotal rows and display overall result of keyfigure
Hello there,
Is there a procedure to hide result of a keyfigure at subtotal level and display result at overall result level?
Please let me know.
Points assured.
regards
JogaHi Daya,
Thanks for the reply. in the report i have other keyfigures also for which i need to show subtotals.
its only for 3 keyfigures i need to hide the subtotal result and show overall result.
when iam hiding the result rows of the key figure iam not getting the result in the overall result column as well.
i only want a result for overall result while supressing the subtotals for 3 keyfigures out of 10 keyfigures.
regards
Joga -
Spry:selected highlights last row and not default
I've seen people post this error, but I'm not finding any simple fixes for this. I'm in Dreamweaver CS4 and I have inserted a spry dataset: Here is my code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:spry="http://ns.adobe.com/spry">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="../SpryAssets/SpryData.js" type="text/javascript"></script>
<script src="../SpryAssets/SpryHTMLDataSet.js" type="text/javascript"></script>
<link href="../SpryAssets/SpryMasterDetail.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
var thur = new Spry.Data.HTMLDataSet("thursday.html", "sprydata");
var fri = new Spry.Data.HTMLDataSet("friday.html", "sprydata");
var sat = new Spry.Data.HTMLDataSet("saturday.html", "sprydata");
//-->
</script>
</head>
<body>
<div class="MasterDetail">
<div spry:region="thur" class="MasterContainer">
<div class="MasterColumn" spry:repeat="thur" spry:setrow="thur" spry:hover="MasterColumnHover" spry:select="MasterColumnSelected" spry:selected="MasterColumnSelected" spry:selectgroup="l" spry:selectedgroup="1">{Activity}</div>
</div>
<div spry:detailregion="thur" class="DetailContainer">
<div class="DetailColumn">{Time}</div>
<div class="DetailColumn">{Activity}</div>
<div class="DetailColumn">{Leaders}</div>
<div class="DetailColumn">{Location}</div>
<div class="DetailColumn">{Fee}</div>
<div class="DetailColumn">{Description}</div>
<div class="DetailColumn">{Flag}</div>
</div>
<br style="clear:both" />
</div>
<div class="MasterDetail">
<div spry:region="fri" class="MasterContainer">
<div class="MasterColumn" spry:repeat="fri" spry:setrow="fri" spry:hover="MasterColumnHover" spry:select="MasterColumnSelected" spry:selected="MasterColumnSelected" spry:selectgroup="2" spry:selectedgroup="2">{Activity}</div>
</div>
<div spry:detailregion="fri" class="DetailContainer">
<div class="DetailColumn">{Time}</div>
<div class="DetailColumn">{Activity}</div>
<div class="DetailColumn">{Leaders}</div>
<div class="DetailColumn">{Location}</div>
<div class="DetailColumn">{Fee}</div>
<div class="DetailColumn">{Description}</div>
<div class="DetailColumn">{Flag}</div>
</div>
<br style="clear:both" />
</div>
<div class="MasterDetail">
<div spry:region="sat" class="MasterContainer">
<div class="MasterColumn" spry:repeat="sat" spry:setrow="sat" spry:hover="MasterColumnHover" spry:select="MasterColumnSelected" spry:selected="MasterColumnSelected" spry:selectgroup="3" spry:selectedgroup="3">{Activity}</div>
</div>
<div spry:detailregion="sat" class="DetailContainer">
<div class="DetailColumn">{Time}</div>
<div class="DetailColumn">{Activity}</div>
<div class="DetailColumn">{Leaders}</div>
<div class="DetailColumn">{Location}</div>
<div class="DetailColumn">{Fee}</div>
<div class="DetailColumn">{Description}</div>
<div class="DetailColumn">{Flag}</div>
</div>
<br style="clear:both" />
</div>
</body>
</html>
When I added the spry:selected function it highlighted the last row in the master column, versus the first row, for which it's displaying details in the details region. Am I missing a small bit of simple code?Alright, I got it working...
This is for multi spry datasets (3 on one page: thur, fri and sat), highlighting the default (first) selected row/record on the left master list (which is the Dreamweaver CS4 default for master/detail, but it doesn't automatically highlight it as "selected") of EACH dataset (using spry:selectgroup and spry:selectedgroup).
The only variables that you would change are the following:
- all the thur, fri, and sat (as in spry:region="thur")
- all the group numbers (as in spry:selectgroup="1")
- all the items in {} (as in {Activity})
- of course all the file names (as in "thursday.html")
All the class names (as in "MasterColumnHover") are all the Dreamweaver CS4 defaults.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:spry="http://ns.adobe.com/spry">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="../SpryAssets/SpryData.js" type="text/javascript"></script>
<script src="../SpryAssets/SpryHTMLDataSet.js" type="text/javascript"></script>
<link href="../SpryAssets/SpryMasterDetail.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
var thur = new Spry.Data.HTMLDataSet("thursday.html", "sprydata");
var fri = new Spry.Data.HTMLDataSet("friday.html", "sprydata");
var sat = new Spry.Data.HTMLDataSet("saturday.html", "sprydata");
//-->
</script>
</head>
<body>
<div class="MasterDetail">
<div spry:region="thur" class="MasterContainer">
<div spry:repeat="thur" spry:choose="choose">
<div spry:when="{ds_RowID} == {ds_CurrentRowID}" class="MasterColumn" spry:setrow="thur" spry:hover="MasterColumnHover" spry:selected="selected" spry:selectedgroup="1" spry:select="MasterColumnSelected" spry:selectgroup="1">{Activity}</div>
<div spry:default="default" class="MasterColumn" spry:setrow="thur" spry:hover="MasterColumnHover" spry:select="MasterColumnSelected" spry:selectgroup="1">{Activity}</div>
</div></div>
<div spry:detailregion="thur" class="DetailContainer">
<div class="DetailColumn">{Time}</div>
<div class="DetailColumn">{Activity}</div>
<div class="DetailColumn">{Leaders}</div>
<div class="DetailColumn">{Location}</div>
<div class="DetailColumn">{Fee}</div>
<div class="DetailColumn">{Description}</div>
<div class="DetailColumn">{Flag}</div>
</div>
<br style="clear:both" />
</div>
<div class="MasterDetail">
<div spry:region="fri" class="MasterContainer">
<div spry:repeat="fri" spry:choose="choose">
<div spry:when="{ds_RowID} == {ds_CurrentRowID}" class="MasterColumn" spry:setrow="fri" spry:hover="MasterColumnHover" spry:selected="selected" spry:selectedgroup="2" spry:select="MasterColumnSelected" spry:selectgroup="2">{Activity}</div>
<div spry:default="default" class="MasterColumn" spry:setrow="fri" spry:hover="MasterColumnHover" spry:select="MasterColumnSelected" spry:selectgroup="2">{Activity}</div>
</div></div>
<div spry:detailregion="fri" class="DetailContainer">
<div class="DetailColumn">{Time}</div>
<div class="DetailColumn">{Activity}</div>
<div class="DetailColumn">{Leaders}</div>
<div class="DetailColumn">{Location}</div>
<div class="DetailColumn">{Fee}</div>
<div class="DetailColumn">{Description}</div>
<div class="DetailColumn">{Flag}</div>
</div>
<br style="clear:both" />
</div>
<div class="MasterDetail">
<div spry:region="sat" class="MasterContainer">
<div spry:repeat="sat" spry:choose="choose">
<div spry:when="{ds_RowID} == {ds_CurrentRowID}" class="MasterColumn" spry:setrow="sat" spry:hover="MasterColumnHover" spry:selected="selected" spry:selectedgroup="3" spry:select="MasterColumnSelected" spry:selectgroup="3">{Activity}</div>
<div spry:default="default" class="MasterColumn" spry:setrow="sat" spry:hover="MasterColumnHover" spry:select="MasterColumnSelected" spry:selectgroup="3">{Activity}</div>
</div></div>
<div spry:detailregion="sat" class="DetailContainer">
<div class="DetailColumn">{Time}</div>
<div class="DetailColumn">{Activity}</div>
<div class="DetailColumn">{Leaders}</div>
<div class="DetailColumn">{Location}</div>
<div class="DetailColumn">{Fee}</div>
<div class="DetailColumn">{Description}</div>
<div class="DetailColumn">{Flag}</div>
</div>
<br style="clear:both" />
</div>
</body>
</html> -
How do I select a date column and display the millesecond along with it.
I am trying to select a date column from database and want to
display millesecond with it. How do I do this. I am aware of
the "alter session set NLS_DATE_FORMAT = 'MM/DD/YY HH:MI:SS'"
command. However, I do not know how to display this with the
millesecond.
Thanks for all the help.Example:
SQL> CREATE OR REPLACE JAVA SOURCE
2 NAMED "MyTimestamp"
3 AS
4 import java.lang.String;
5 import java.sql.Timestamp;
6
7 public class MyTimestamp
8 {
9 public static String getTimestamp()
10 {
11 return (new
12 Timestamp(System.currentTimeMillis())).toString();
13 }
14 };
15 /
Java created.
SQL> CREATE OR REPLACE FUNCTION my_timestamp
2 RETURN VARCHAR2
3 AS LANGUAGE JAVA
4 NAME 'MyTimestamp.getTimestamp() return java.lang.String';
5 /
Function created.
SQL> CREATE TABLE test_time
2 (date_col VARCHAR2 (23))
3 /
Table created.
SQL> INSERT INTO test_time (date_col)
2 SELECT my_timestamp
3 FROM dual
4 /
1 row created.
SQL> SELECT date_col
2 FROM test_time
3 /
DATE_COL
2001-11-02 14:58:51.766 -
SELECTing from multiple rows and different tables
Basically, I have a table with a primary key and some other columns of data. The second table has a foreign key that points to the first table then has a columns with related data. I want to write construct a SQL query where one of the columns is the primary key from the first table and the second column is a concatenation of all the rows in the second table that have the same foreign key.
I need this in the form of one SQL statement so that I can use it to create a report in Application ExpressJust in case my first post was a bit unclear.
My first table has a primary key, INTERACTION_ID, and several other columns of data.
My second table has a foreign key, INTERACTION_ID, and one extra column, USER_NAME.
There are several rows in the second table that share the same INTERACTION_ID as each interaction can have many user names. I want to construct a SQL query where I pull the interaction id in one column and concatenate all the relevant rows of USER_NAME as the second column. -
Column is summing up all the rows and displaying same value in all rows.
Hi,
Kindly see the below query. I have a problem in this query to fetch the abs_qty when the parameter P:item ie)msib.segment1 is not given as the input parameter. Its just summing up the entire quantity for all the items.When I pass P:item ie)msib.segment1 as input parameter, It fetches the exact value for abs_qty. Kindly help me to resolve this.
Note only : Manufacturing plant ,Start date and End Date are Mandatory(required) parameters. Others like Item,Base Model and Planner code are optional.
SELECT mmt.transaction_date date_produced, msib.segment1 item,
cic.cost_type_id, msib.description item_description,
mc.segment6 base_model, mc.segment7 trade_brand,
mmt.subinventory_code subinventory,
mil.segment1 || '.' || mil.segment2 || '.' || mil.segment3 LOCATOR,
ood.organization_code
|| '-'
|| ood.organization_name manufacturing_plant,
mmt.transaction_quantity quantity_produced,
mtt.transaction_type_name transaction_type, msib.inventory_item_id,
msib.organization_id, cic.material_cost COST,
cic.material_overhead_cost freight, csc.standard_cost,
*(select (NVL((SELECT SUM (mmt.transaction_quantity) total_NET_qty*
FROM mtl_material_transactions mmt,
mtl_system_items_b msib,
mtl_transaction_types mtt,
org_organization_definitions ood,
mtl_txn_source_types mts
WHERE mmt.organization_id = msib.organization_id
AND msib.inventory_item_id = mmt.inventory_item_id
AND mmt.transaction_type_id = mtt.transaction_type_id
AND mmt.organization_id = ood.organization_id
AND mtt.transaction_type_name = 'WIP Completion'
AND mts.transaction_source_type_name = 'Job or Schedule'
AND msib.segment1 = NVL (:p_item, msib.segment1)
AND ood.organization_code = :p_manufacturing_plant
AND TRUNC (mmt.transaction_date) BETWEEN :p_start_date
AND :p_end_date ),0)
*(NVL((SELECT SUM (mmt.transaction_quantity) total_NET_qty*
FROM mtl_material_transactions mmt,
mtl_system_items_b msib,
mtl_transaction_types mtt,
org_organization_definitions ood,
mtl_txn_source_types mts
WHERE mmt.organization_id = msib.organization_id
AND msib.inventory_item_id = mmt.inventory_item_id
AND mmt.transaction_type_id = mtt.transaction_type_id
AND mmt.organization_id = ood.organization_id
AND mtt.transaction_type_name = 'WIP Issue'
AND mts.transaction_source_type_name = 'Job or Schedule'
AND msib.segment1 = NVL (:p_item, msib.segment1)
AND ood.organization_code = :p_manufacturing_plant
AND TRUNC (mmt.transaction_date) BETWEEN :p_start_date
AND :p_end_date
*),0))) abs_qty from dual) AS ABS_qtyy,*(select (NVL((SELECT SUM (mmt.transaction_quantity) total_NET_qty
FROM mtl_material_transactions mmt,
mtl_system_items_b msib,
mtl_transaction_types mtt,
org_organization_definitions ood,
mtl_txn_source_types mts
WHERE mmt.organization_id = msib.organization_id
AND msib.inventory_item_id = mmt.inventory_item_id
AND mmt.transaction_type_id = mtt.transaction_type_id
AND mmt.organization_id = ood.organization_id
AND mtt.transaction_type_name = 'WIP Completion'
AND mts.transaction_source_type_name = 'Job or Schedule'
AND msib.segment1 = NVL (:p_item, msib.segment1)
AND ood.organization_code = :p_manufacturing_plant
AND TRUNC (mmt.transaction_date) BETWEEN :p_start_date
AND :p_end_date ),0)
(NVL((SELECT SUM (mmt.transaction_quantity) total_NET_qty
FROM mtl_material_transactions mmt,
mtl_system_items_b msib,
mtl_transaction_types mtt,
org_organization_definitions ood,
mtl_txn_source_types mts
WHERE mmt.organization_id = msib.organization_id
AND msib.inventory_item_id = mmt.inventory_item_id
AND mmt.transaction_type_id = mtt.transaction_type_id
AND mmt.organization_id = ood.organization_id
AND mtt.transaction_type_name = 'WIP Issue'
AND mts.transaction_source_type_name = 'Job or Schedule'
AND msib.segment1 = NVL (:p_item, msib.segment1)
AND ood.organization_code = :p_manufacturing_plant
AND TRUNC (mmt.transaction_date) BETWEEN :p_start_date
AND :p_end_date
),0))) abs_qty from dual)*csc.standard_cost AS abs_val
FROM mtl_material_transactions mmt,
mtl_system_items_b msib,
mtl_item_locations mil,
mtl_transaction_types mtt,
org_organization_definitions ood,
mtl_txn_source_types mts,
mtl_categories mc,
mtl_item_categories mic,
mtl_category_sets mcs,
cst_item_costs cic,
cst_standard_costs csc,
cst_cost_types ct,
mfg_lookups mlo
WHERE mmt.organization_id = msib.organization_id
AND msib.inventory_item_id = mmt.inventory_item_id
AND mmt.locator_id = mil.inventory_location_id
AND mil.organization_id = msib.organization_id
AND mil.subinventory_code = mmt.subinventory_code
AND mmt.transaction_type_id = mtt.transaction_type_id
AND msib.organization_id = ood.organization_id
AND mic.category_set_id = mcs.category_set_id
AND mc.category_id = mic.category_id
AND mc.structure_id = mcs.structure_id
AND mic.inventory_item_id = msib.inventory_item_id
AND mic.organization_id = msib.organization_id
AND mcs.category_set_id = 52487965
AND msib.inventory_item_id = cic.inventory_item_id
AND msib.organization_id = cic.organization_id
AND ct.cost_type_id = cic.cost_type_id
AND cic.organization_id = ood.organization_id
AND mil.inventory_location_id = mmt.locator_id
AND mmt.transaction_source_type_id = mtt.transaction_source_type_id
AND mmt.transaction_action_id = mtt.transaction_action_id
AND mmt.transaction_source_type_id = mts.transaction_source_type_id
AND mmt.transaction_action_id = mlo.lookup_code
AND mmt.inventory_item_id = csc.inventory_item_id
AND mmt.organization_id = csc.organization_id
AND csc.last_update_date >=
(SELECT MAX (csc1.last_update_date)
FROM cst_standard_costs csc1
WHERE csc1.inventory_item_id = mmt.inventory_item_id
AND csc1.organization_id = mmt.organization_id)
AND msib.segment1 = NVL (:p_item, msib.segment1)
AND NVL (mc.segment6, 'X') = NVL (:p_base_model, NVL (mc.segment6, 'X'))
AND NVL (msib.planner_code, 'Y') =
NVL (:p_planner_code, NVL (msib.planner_code, 'Y'))
AND UPPER (mlo.meaning) = 'ASSEMBLY COMPLETION'
AND mtt.transaction_type_name = 'WIP Completion'
AND ct.cost_type = 'Frozen'
AND mts.transaction_source_type_name = 'Job or Schedule'
AND ood.organization_code = :p_manufacturing_plant
AND TRUNC (mmt.transaction_date) BETWEEN :p_start_date AND :p_end_dateIf <tt>abs_qty</tt> and consequently <tt>abs_val</tt> should not be the same for all rows returned, you'll have to rewrite your query so that the <tt>abs_qty</tt> won't be computed in isolation (separately) with no interaction with data from the main from table list.
Your query is treated the same as the one below (note the changed table aliases by appending numbers to the originals of yours)
SELECT mmt.transaction_date date_produced,
msib.segment1 item,
cic.cost_type_id,
msib.description item_description,
mc.segment6 base_model,
mc.segment7 trade_brand,
mmt.subinventory_code subinventory,
mil.segment1 || '.' || mil.segment2 || '.' || mil.segment3 LOCATOR,
ood.organization_code || '-' || ood.organization_name manufacturing_plant,
mmt.transaction_quantity quantity_produced,
mtt.transaction_type_name transaction_type,
msib.inventory_item_id,
msib.organization_id,
cic.material_cost COST,
cic.material_overhead_cost freight,
csc.standard_cost,
(select (NVL(
(SELECT SUM (mmt1.transaction_quantity) total_NET_qty
FROM mtl_material_transactions mmt1,
mtl_system_items_b msib1,
mtl_transaction_types mtt1,
org_organization_definitions ood1,
mtl_txn_source_types mts1
WHERE mmt1.organization_id = msib1.organization_id
AND msib1.inventory_item_id = mmt1.inventory_item_id
AND mmt1.transaction_type_id = mtt1.transaction_type_id
AND mmt1.organization_id = ood1.organization_id
AND mtt1.transaction_type_name = 'WIP Completion'
AND mts1.transaction_source_type_name = 'Job or Schedule'
AND msib1.segment1 = NVL (:p_item, msib1.segment1)
AND ood1.organization_code = :p_manufacturing_plant
AND TRUNC (mmt1.transaction_date) BETWEEN :p_start_date AND :p_end_date
),0
) - NVL(
(SELECT SUM (mmt2.transaction_quantity) total_NET_qty
FROM mtl_material_transactions mmt2,
mtl_system_items_b msib2,
mtl_transaction_types mtt2,
org_organization_definitions ood2,
mtl_txn_source_types mts2
WHERE mmt2.organization_id = msib2.organization_id
AND msib2.inventory_item_id = mmt2.inventory_item_id
AND mmt2.transaction_type_id = mtt2.transaction_type_id
AND mmt2.organization_id = ood.2organization_id
AND mtt2.transaction_type_name = 'WIP Issue'
AND mts2.transaction_source_type_name = 'Job or Schedule'
AND msib2.segment1 = NVL (:p_item, msib2.segment1)
AND ood2.organization_code = :p_manufacturing_plant
AND TRUNC (mmt.2transaction_date) BETWEEN :p_start_date AND :p_end_date
),0
) abs_qty
from dual
) AS ABS_qtyy,
(select (NVL(
(SELECT SUM (mmt3.transaction_quantity) total_NET_qty
FROM mtl_material_transactions mmt3,
mtl_system_items_b msib3,
mtl_transaction_types mtt3,
org_organization_definitions ood3,
mtl_txn_source_types mts3
WHERE mmt3.organization_id = msib3.organization_id
AND msib3.inventory_item_id = mmt3.inventory_item_id
AND mmt3.transaction_type_id = mtt3.transaction_type_id
AND mmt3.organization_id = ood3.organization_id
AND mtt3.transaction_type_name = 'WIP Completion'
AND mts3.transaction_source_type_name = 'Job or Schedule'
AND msib3.segment1 = NVL (:p_item, msib3.segment1)
AND ood3.organization_code = :p_manufacturing_plant
AND TRUNC (mmt3.transaction_date) BETWEEN :p_start_date AND :p_end_date
),0
) - NVL(
(SELECT SUM (mmt4.transaction_quantity) total_NET_qty
FROM mtl_material_transactions mmt4,
mtl_system_items_b msib4,
mtl_transaction_types mtt4,
org_organization_definitions ood4,
mtl_txn_source_types mts4
WHERE mmt4.organization_id = msib4.organization_id
AND msib4.inventory_item_id = mmt4.inventory_item_id
AND mmt4.transaction_type_id = mtt4.transaction_type_id
AND mmt4.organization_id = ood4.organization_id
AND mtt4.transaction_type_name = 'WIP Issue'
AND mts4.transaction_source_type_name = 'Job or Schedule'
AND msib4.segment1 = NVL (:p_item, msib4.segment1)
AND ood4.organization_code = :p_manufacturing_plant
AND TRUNC (mmt4.transaction_date) BETWEEN :p_start_date AND :p_end_date
),0
) abs_qty
from dual
) * csc.standard_cost AS abs_val
FROM mtl_material_transactions mmt,
mtl_system_items_b msib,
mtl_item_locations mil,
mtl_transaction_types mtt,
org_organization_definitions ood,
mtl_txn_source_types mts,
mtl_categories mc,
mtl_item_categories mic,
mtl_category_sets mcs,
cst_item_costs cic,
cst_standard_costs csc,
cst_cost_types ct,
mfg_lookups mlo
WHERE mmt.organization_id = msib.organization_id
AND msib.inventory_item_id = mmt.inventory_item_id
AND mmt.locator_id = mil.inventory_location_id
AND mil.organization_id = msib.organization_id
AND mil.subinventory_code = mmt.subinventory_code
AND mmt.transaction_type_id = mtt.transaction_type_id
AND msib.organization_id = ood.organization_id
AND mic.category_set_id = mcs.category_set_id
AND mc.category_id = mic.category_id
AND mc.structure_id = mcs.structure_id
AND mic.inventory_item_id = msib.inventory_item_id
AND mic.organization_id = msib.organization_id
AND mcs.category_set_id = 52487965
AND msib.inventory_item_id = cic.inventory_item_id
AND msib.organization_id = cic.organization_id
AND ct.cost_type_id = cic.cost_type_id
AND cic.organization_id = ood.organization_id
AND mil.inventory_location_id = mmt.locator_id
AND mmt.transaction_source_type_id = mtt.transaction_source_type_id
AND mmt.transaction_action_id = mtt.transaction_action_id
AND mmt.transaction_source_type_id = mts.transaction_source_type_id
AND mmt.transaction_action_id = mlo.lookup_code
AND mmt.inventory_item_id = csc.inventory_item_id
AND mmt.organization_id = csc.organization_id
AND csc.last_update_date >= (SELECT MAX (csc1.last_update_date)
FROM cst_standard_costs csc1
WHERE csc1.inventory_item_id = mmt.inventory_item_id
AND csc1.organization_id = mmt.organization_id
AND msib.segment1 = NVL (:p_item, msib.segment1)
AND NVL (mc.segment6, 'X') = NVL (:p_base_model, NVL (mc.segment6, 'X'))
AND NVL (msib.planner_code, 'Y') = NVL (:p_planner_code, NVL (msib.planner_code, 'Y'))
AND UPPER (mlo.meaning) = 'ASSEMBLY COMPLETION'
AND mtt.transaction_type_name = 'WIP Completion'
AND ct.cost_type = 'Frozen'
AND mts.transaction_source_type_name = 'Job or Schedule'
AND ood.organization_code = :p_manufacturing_plant
AND TRUNC (mmt.transaction_date) BETWEEN :p_start_date AND :p_end_dateRegards
Etbin -
Requirement - I am writing a very large reports from Hyperion Performance Cost management.
Account is in Row. We are taking all level0 members in Row. In columns we are taking Entity,Cost Centers
Current Structure of the Report
41100 Entity1 Cost center1 20
41100 Entity1 Cost center2 30
41100 Entity1 Cost cenetr3 40
41200 Entity 10 Cost center1 200
41200 Entity 10 Cost center2 210
41200 Entity 10 Cost center3 200
Grand Total 1000 ( For Example)
User wants to dynamically add a sub total into the report when account (41200,41100) changes i.e. This is because , its a very large report of 100's of pages,
Future State
41100 Entity1 Cost center1 20
41100 Entity1 Cost center2 30
41100 Entity1 Cost cenetr3 40
sub total 1 --------------------------90 ( This line should be automatically inserted here)
41200 Entity 10 Cost center1 200
41200 Entity 10 Cost center2 210
41200 Entity 10 Cost center3 200
sub total (n) -------------------------610 ( This line should be automatically inserted here)
Grand Total 1000 ( For Example)Hello,
maybe re-consider this approach and say no to the users who request this. Try to think about other solutions.
Sometimes a "no" helps them more than doing what they ask.
You might export the whole in Excel. Then they can make their subtotals at every line.
Regards,
Philip. -
Selecting the first n rows with Oracle
Please help,I am very confused with this.
For example,lets take a table called "items" which has
ID NAME PRICE
1 cup 1.2
2 book 49.99
3 mobile 89.99
20 bike 1250
19 egg 0.8
18 bun 2.5
17 color 2.22
16 tv 310
15 air 0
14 laptop 999.5
13 pack 21.53
12 cd/r 1.2
11 table 198
10 apple 1.05
9 carpet 122.4
8 oracle 19999
7 door 150
6 dollar 1
5 pencil 1.35
Next,say, we want to retrieve the five cheapest items.
select name, price
from items
where rownum < 6
order by price;
NAME PRICE
coke .78
cup 1.2
pencil 1.35
book 49.99
mobile 89.99
This is wrong. In the result set above, the item with id no 19 (egg) is missing which only costs 0.80 (currency units). We get this because
Oracle first retrieves the first five rows and then orders them by price. This is because of the fact that we didn't explicitly enough state what we meant with first.
This problem can be solved by using row_number with a option--->below
select name, price
from (
_*select name, price, row_number() over (order by price) r*_
_*from items*_
where r between 1 and 5;
NAME PRICE
air 0
coke .78
egg .8
dollar 1
apple 1.05
**Question is in the above select if i ADD the clause "WHERE rownum <= 6"---The above result set goes wrong again.I dont get the correct order as above.
Please help.Can we have the order by done first and then take 5 records of them.
select name, price
from (
select name, price, row_number() over (order by price) r
*from items WHERE rownum <= 6*
where r between 1 and 5wrote:user_7000011
Thanks.
*But, what i wanted is in the inner most select where we select from item --I need to add a where qualification as below.*
select * from
(select name, price, dense_rank() over (ORDER by price desc ) rank from item where rownum <=6
) a
where a.rank<6
Well, the rank limitation is having the same effect in that query, so there's no need to try and put "rownum <=6" in that case.What you need to understand is that "rownum" is a pseudo column that is generated when the results of a query are already determined, but it is applied before any ordering takes place (as the where clause is evaluated before the order by clause).
So if you try and say "where rownum <= 6 order by x", you are under the misunderstanding that it will order the data first and then take the first 6 rows. This isn't the case. It will take the first 6 rows (whatever they may be) and then order those.
In order to order first and then take 6 rows you have to order your data without restriction and then wrap that in a query to restrict it.
Hence...
select x
from tableX
where rownum <= 6
order by xbecomes
select x
from (select x
from tableX
order by x)
where rownum <= 6This ensures that the data is selected and ordered first and then the first 6 rows are taken from that.
Maybe you are looking for
-
Reading dilimited input from a text file with tokenizer
i am trying to read in a text file with the following structure: 2 integers on each line with comma as the delimitor. i am using the BufferedReader stream and Tokenizer to detect ",". try { BufferedReader in = new BufferedReader(new FileReader(filena
-
I have several songs I deleted on an unknown date that I want to redownload. As I stated in the title, the songs I am looking for are not in my "Purchases" list, and when I search for the album the song is in the song has a greyed-out "Purchased" but
-
BenQ XL2420T 120 HZ / 3D Ready - May I use this with my iMac?
Hi. My Philips 190B monitor that I have been using with my iMac in Extended Desktop mode recently died so I'm looking for a replacement second monitor. I also own a PS3. Well, actually I own two. One is sick at the moment. I would like to replace th
-
Apple tv 2 wake mac running lion
Hi, Ok so every night I put my iMac to sleep and every morning my kids are telling me to wake up the iMac because there is no library showing in Apple TV 2. But I have my System Prefs set to wake for network access. What am I missing and what do I
-
when I am installing sql server 2012 I get the following message. Windows 8.1 SQL Server 2012 sp1 I have searched for solutions but I could not install