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

Similar Messages

  • 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

  • I NEED A FIRST 5 ROWS DATA

    HI EXPORTS,
    MY QURY IS
    SELECT TOT.HTNO, TOT.RESULT_NAME, TOT.TOTALMARKS, TOT.TOTALRANK,
    TOT.RESEXAMSLNO, TOT.RESACADEMICSLNO, TOT.RESGROUPSLNO,
    TOT.RESCORPCOLLSLNO, TOT.DISTRICTSLNO
    FROM RESULT_STUDENTMARKS_TOTALS TOT
    WHERE TOT.RESEXAMSLNO = 1
    AND TOT.RESGROUPSLNO = 1
    AND TOT.RESACADEMICSLNO = 9
    AND TOT.RESCORPCOLLSLNO IN (99)
    AND TOT.DISTRICTSLNO IN (4)
    AND ROWNUM <5
    ORDER BY TOT.HTNO
    I WANT FIRST 4 ROWS OF DATA BASED ON ASSENDING ORDER CAN U CHAGE IS QURY OR
    GIVEN ANY EXAMPLE OF FIRST 4 ROWS OF DATA ORDER BY ONLY ONE FIELD IN THAT TABLE
    THANX & REGARDS
    ASHOK
    Edited by: Ashok on Apr 28, 2011 11:01 PM

    See
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:62364503028143
    and
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:2853107469873
    You have to filter the ROWNUM after the ORDER BY.
    so :
    select * from
    SELECT TOT.HTNO, TOT.RESULT_NAME, TOT.TOTALMARKS, TOT.TOTALRANK,
    TOT.RESEXAMSLNO, TOT.RESACADEMICSLNO, TOT.RESGROUPSLNO,
    TOT.RESCORPCOLLSLNO, TOT.DISTRICTSLNO
    FROM RESULT_STUDENTMARKS_TOTALS TOT
    WHERE TOT.RESEXAMSLNO = 1
    AND TOT.RESGROUPSLNO = 1
    AND TOT.RESACADEMICSLNO = 9
    AND TOT.RESCORPCOLLSLNO IN (99)
    AND TOT.DISTRICTSLNO IN (4)
    ORDER BY TOT.HTNO
    where rownum < 6
    order by 1Hemant K Chitale
    Edited by: Hemant K Chitale on Apr 29, 2011 2:28 PM
    Changed "rownum < 5" to "rownum < 6" to get 5 rows.

  • Show Only First N Rows in SAP Design Studio Chart/Table

    Hi,
    Is it possible to show only first N rows of data in SAP Design Studio Charts/Cross Tab ?
    Eg
    Bex Query Output
    Here If I mention First 2 rows, my chart looks like below
    If I mention First 4 rows, my chart looks like below
    Thanks
    Anil

    Hi Mustafa,
    Thanks for your reply.
    Actually our requirement is, we have one Bex Query where we are using Ranking Function.
    We have 15 customers, and we need to know the ranking based on some calculations.
    Whenever we execute the query with different time periods, the ranking of Customers will vary, for example if I execute query for year 2014, customer 1 can be Rank 1, If I execute for year 2013, Customer 7 can be Rank 1.
    From this Query I need to show only Top 5 Customers in Cross Tab/Chart.
    We tried to put condition on CY Ranking in Bex to show only Top 5, but the result was giving some diff customers and also for all Time periods we are getting same Customers In Top 5.
    To overcome this, we thought instead of putting condition on Bex side, we are trying to pick only first 5 rows from Bex Query and show them in Chart/Cross Tab, something like we will map only first 5 rows in Xcelcius.
    We would like to know is there any functionality in Design Studio to show only first 5 rows of data.
    Regards,
    Anil

  • How can I select and delete rows based on the value in one column?

    I searched through the discussion board, and found a thread on deleting blank rows, but not sure how to modify it to work with my issue.
    I have put together a rather complicated spreadsheet for designing control systems, it calculates parts needed based on check boxes selected in a second spreadsheet.
    Since not all systems require all parts there are many rows that have a 0 quantity value, I would like to select these rows and delete them once I have gone through the design phase (checking off required features on a separate sheet).
    I like the way the other thread I found will gather all the blank rows at the bottom without changing the order of the rows with data in them.
    I don't understand exactly how the formula in the other thread works well enough to modify it to look for a certain column.
    I hope I made myself clear enough here, to recap, I would like to sort the rows based on a zero value in one (quantity) column, move them (the zero quantity rows) to the bottom of the sheet, and then delete the rows with a zero quantity (I can delete them manually, but would like to automate the sorting part).
    Thanks for any help anyone can provide here.
    Danny

    I apologize but, as far as I know, Numbers wasn't designed by Ian Flemming.
    There is no "this column will be auto-destructing after two minutes"
    You will have to use your fingers to delete it.
    I wish to add a last comment :
    if your boss has the bad habit to look over your shoulder, it's time to find an other one.
    As I am really pig headed, it's what I did. I became my own boss so nobody looked over my shoulder.
    Yvan KOENIG (VALLAURIS, France) mercredi 13 juillet 2011 20:30:25
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8
    Please : Search for questions similar to your own before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • 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 &lt; 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---&gt;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 5

    wrote: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 &lt;=6
    ) a
    where a.rank&lt;6
    Well, the rank limitation is having the same effect in that query, so there's no need to try and put "rownum &lt;=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 &lt;= 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 &lt;= 6
    order by xbecomes
    select x
    from (select x
          from   tableX
          order by x)
    where rownum &lt;= 6This ensures that the data is selected and ordered first and then the first 6 rows are taken from that.

  • Query to split one row to multiple based on date range

    Hi,
    I need to split single row into multple based on date range defined in a column, start_dt and end_dt
    I have a data
    ID      From date             End_dt                measure
    1        2013-12-01         2013-12-03            1
    1        2013-12-04         2013-12-06            2
    2        2013-12-01         2013-12-02            11
    3        2013-12-03         2013-12-04          22
    I required output as
    ID      Date                      measure
    1        2013-12-01              1
    1        2013-12-02              1
    1        2013-12-03              1
    1        2013-12-04              2
    1        2013-12-05              2
    1        2013-12-06              2
    2        2013-12-01             11
    2        2013-12-02             11
    3        2013-12-03             22
    3        2013-12-04            22
    Please provide me sq, query for the same
    Amit
    Please mark as answer if helpful
    http://fascinatingsql.wordpress.com/

    Have a calendar table for example and then probably using UNION ALL from date  and stat date JOIN the Calendar table
    SELECT ID,From date  FROM tbl
    union all
    SELECT ID,End_dt FROM tbl
    with tmp(plant_date) as
       select cast('20130101' as datetime)
       union all
       select plant_date + 1
         from tmp
        where plant_date < '20131231'
    select*
      from  tmp
    option (maxrecursion 0)
    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

  • Af:inputListOfValues popup : selecting first row

    Hi,
    Is there a way to select first row inside lov popup, the by default behaviour is it selects the rowHeader rather than row itself.
    When the lov popup is opened , there is no focus on table resides in the popup
    - to focus on table, user has to press down arrow key - which will just focus on rowHeader and not the actual row itself
    - to focus row for currently selected rowHeader user has to press right arrow key which will then select the table row itself
    its cumbersome everytime when you open lov and do these extra steps to just to select a value from lov
    any ideas?
    Thanks,
    Dev

    so, why it supports keyboard navigation at all? either support full features or nothing. the fact that user can use up/down arrow keys which selects rowHeader of every row , rather than actual row
    regarding "Search and Select : " it could be anything it has nothing to do with row selection,
    Thanks,

  • Display of 2 rows of data for 2 different date range selection

    Hi Folks,
    I have a requirement as follows,
    User has an option of selecting 2 Date Ranges
    From and To Date and again From and To Date
    The result should display 2 different rows of data with From and To Date range selection.
    Eg:
    12/09/20008 to 03/09/2009           10 20 30 40
    23/10/2009 to  18/12/2010           40 20 10 30
    Difference                                   30 0  20 10
    % Change                                   x  y  z   q
    Thanks for your input.
    Regards,
    KJ

    You will need to use union report, and you would have fours union's in this report.
    Union - 1: Data from 1st Date Range
    Union - 2: Data from 2nd Date Range
    Union - 3: Variance Calculation
    Union - 4: Percentage Variance Calculation.
    If the date's are coming from the same field, use cast function to use the same column twice in your prompts. Apply filters on each union as needed.
    Thanks.

  • Selecting single record from multiple record based on date

    Hi experts,
    I have a table which contains the multiple records for single ID No. Now i have to select single record which contains the latest date.
    here is the structure
    Name   Null Type        
    ID_P        NUMBER      
    NAME_P      VARCHAR2(12)
    DATE_P      TIMESTAMP(6)
    Records
    1 loosi     22-AUG-13 01.27.48.000000000 PM
    1 nammi  26-AUG-13 01.28.10.000000000 PM
    2 kk        22-AUG-13 01.28.26.000000000 PM
    2 thej      26-AUG-13 01.28.42.000000000 PM
    now i have to select below 2 rows how can write select qurie for this?
    1 loosi     26-AUG-13 01.27.48.000000000 PM
    2 thej      26-AUG-13 01.28.42.000000000 PM

    Hi,
    You can use the analytic ROW_NUMBER function.
    I don't have a copy of your table, so I'll use scott.emp to illustrate.  In scott.emp, there may be multiple rows for a single job.  To display just 1 row per job, the row with the most recent hiredate:
    WITH got_r_num AS
         SELECT  empno, job, deptno, hiredate -- Or whatever columns you want
         ,       ROW_NUMBER () OVER ( PARTITION BY  job
                                      ORDER BY      hiredate DESC
                                    )  AS r_num
        FROM    scott.emp
    --  WHERE ...   -- If you need any filtering put it here
    SELECT   *      -- Or list all columns except r_num
    FROM     got_r_num
    WHERE    r_num   = 1
    What results do you want in case of ties?  Depending on your requirements, you may want to add tie-breaking expressions to the analytic ORDER BY clause, and/or use RANK instead of ROW_NUMBER.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    Point out where the query above is producing the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
    If you modify the query at all, post your modified version.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • How to activate a different sub-report for each row in the data set as main report page breaks on each row of data in the main dataset

    I am going to try asking this same question a different way as I have yet to find a working solution to my problem.  I have a main report and then 8 sub reports.  My main report has one data set and returns one row of data per account number.  One
    of the fields in the main data set is called AccountProf.  My main report displays one page per Account number and then calls a different sub report based on that account's AccountProf value.  The sub reports take in the account number as a parameter
    and get multiple rows of data to display that accounts usage formatted differntly for each AccountProf (hence the 8 different sub report.  
    So far I can figure out how to do everything but setting the visibility property of each sub-reports when I have multiple accounts.  If I use the following expression for the visibility property on each sub report, it makes all the applicable sub report
    for all the accounts requested visible at once:
    =IIF(Fields!AccountProf.Value= "USE_PLUS_DMD",False,True)
    *The value in bold USE_PLUS_DMD  is different for each sub report.
    Here is a look at what the main report look like:
    Here is the main reports data set:

    Hi JasonDWilson77,
    According to your description, there is a main report and 8 sub reports in the report, you want to set visibility of sub reports, if no value is passed to the parameter of sub report, the sub report will not be displayed. If that is the case, please refer
    to the following steps:
      1. Create a new parameter named NewAccountNumber, set its data type the same as @AccountNumber, select Allow multiple values, set Visibility to be hidden, then set all available values to default values.
      2. Right-click the first sub report and open Subreport Properties dialog box, click Parameters in left pane, set name to AccountNumber, then click (fx) button, type the expression like below:
    =Parameters! NewAccountNumber(0)
      3. Click Visibility in left pane, select Show or hide based on an expression, then click (fx) button and type the expression like below:
    =IIF(InStr(Join(Parameters! AccountNumber.Value), Parameters!NewAccountNumber.Value(0))>0 , false,true)
      4. Modify parameter of other sub reports like step2.
      5. Set visibility of other sub reports like step3.
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    If you have any feedback on our support, please click
    here.
    Wendy Fu
    TechNet Community Support

  • Relationship between header and row level data.

    Hi all
    I need to know how to relate a field in the header level and the row level...
    On my row level i want the route id to be related to the route name field at the header level...instead of showing this route id  it must show only the header so...based on the row level data the header must change...
    I tried insertin the field but when i do a relate to on either fields its showing me only fields on that catagory ( Header only or Row Level only)
    Thanks

    The Header is evaluated and printed first and then only Repetitive area is computed and printed. You cannot try to arrive header based on the Repetitive area.
    Please explain in detail which screen etc.. so that we can suggest some work arounds

  • Multiple clobs in a single row of data

    I have several clobs in a single row of data and have created a procedure where I attempt to display the first 4k of each clob.
    using a for loop cursor I select all of the clobs in a row at the same time and then I use dbms_lob.read to get the first 4k of data.
    For the first lob of each row everything works fine but when I attempt to dbms_lob.read the second one I get an "ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275" and I'm not sure why?
    does anyone know of an example where two or more clobs are selected and then converted to 4K varchars?
    sample columns for the table:
    SPECIALREQUIREMENTSS     CLOB
    REFERENCERANGE     CLOB
    ALERTVALUE     CLOB
    REFERENCELAB     VARCHAR2(50 CHAR)
    TESTINCLUDES     CLOB
    LASTUPDATE     DATE
    sample code (I removed some code for clairity - this produces the same error):
    create or replace
    procedure test_lobs as
    v_lab_blob blob;
    v_lobamt binary_integer := 32767;
    v_lobpos pls_integer := 1;
    v_labrec labman.lab_testingdata%rowtype;
    v_buffer varchar2(32767) :='';
    v_start_left number;
    begin
    -- *** housekeeping
    dbms_lob.createtemporary(v_labrec.testincludes,TRUE);
    dbms_lob.createtemporary(v_labrec.specialrequirementss,TRUE);
    Plpdf.init;
    Plpdf.NewPage;
    Plpdf.SetColor4Drawing(66,66,66);
    Plpdf.SetColor4Filling(180,180,180);
    v_start_left := Plpdf.GetPageWidth-Plpdf.GetPageRightSpace;
    -- *** select the test name for shaded printing
    for x in (select indexnumber, test from labman.lab_testingdata where test like 'A%') loop
    -- *** select the test data for printing
    select * into v_labrec from labman.lab_testingdata where indexnumber = x.indexnumber;
    -- *** test includes
    if dbms_lob.getlength(v_labrec.testincludes) > 0 or v_labrec.testincludes is not null then
    Plpdf.SetPrintFont('Arial','B',8);
    Plpdf.LineBreak(.1);
    Plpdf.PrintCell(25,5,'Test Includes:',0,0,'R',0,null,0);
    Plpdf.SetPrintFont('Arial',null,8);
    if dbms_lob.getlength(v_labrec.testincludes) > 32767 then
    v_buffer := '*** error - text is greater than 32k ***';
    else
    v_lobamt := 32767;
    v_buffer := '';
    dbms_lob.read(v_labrec.testincludes,v_lobamt,v_lobpos,v_buffer);
    end if;
    Plpdf.SetLeftMargin(Plpdf.GetCurrentX);
    Plpdf.PrintFlowingText(5,v_buffer,null,0);
    Plpdf.SetLeftMargin(v_start_left);
    Plpdf.lineBreak;
    end if;
    -- *** special requirements
    Plpdf.SetPrintFont('Arial','B',8);
    Plpdf.LineBreak(.1);
    Plpdf.PrintCell(25,5,'Special Requirements:',0,0,'R',0,null,0);
    Plpdf.SetPrintFont('Arial',null,8);
    if dbms_lob.getlength(v_labrec.specialrequirementss) > 32767 then
    v_buffer := '*** error - text is greater than 32k ***';
    elsif dbms_lob.getlength(v_labrec.specialrequirementss) = 0 then
    v_buffer := '';
    else
    v_lobamt := 32767;
    v_buffer := '';
    dbms_lob.read(v_labrec.specialrequirementss,v_lobamt,v_lobpos,v_buffer);
    end if;
    Plpdf.SetLeftMargin(Plpdf.GetCurrentX);
    Plpdf.PrintFlowingText(5,v_buffer,null,0);
    Plpdf.SetLeftMargin(v_start_left);
    Plpdf.lineBreak;
    commit;
    end loop;
    Plpdf.SendDoc(v_lab_blob);
    -- store the PDF document
    delete from store_blob;
    commit;
    INSERT INTO STORE_BLOB (blob_file, created_date)
    VALUES (v_lab_blob, SYSDATE);
    COMMIT;
    end test_lobs;

    didn't think that checking for a length of zero and null would produce two different results - should have known better.
    Thanks for your help!
    elsif dbms_lob.getlength(v_labrec.specialrequirementss) = 0
    or v_labrec.specialrequirementss is null then

  • How to determine the number of rows of data in a datatable?

    I have a datatable that I fill from an SQL query.  I do not know exactly how many rows of data it will return (due to my selection criteria) but will be somewhere between 100 and 300 rows.  I send this data into a report but need to determine the length of the report (panel height data member) programatically based on how much data the query has returned.  So, I need a way to count how many rows are filled in the data table.
    I tried doing a nested "if" statement checking the value of each cell but when I tested the expression at 59 "if" statements (will need 300+) I got a parser error in lookout when I tried to accept the connection.  I also tried a type of loop by assigning cursor.2 either to its own value (circular) or to its own value plus one depending on the value of the cell at cursor.2.  It was close but overshot by one row or more (much more sometimes).
    Any clever ideas?  Perhaps I have just been looking at this problem too long.  Thanks, in advance, for your help.

    Since the datatable gets the data from the SQL query, you can also use the SQL statement to count the number of rows in the query result.  
    For example, in datatable you do "select localtime, trace1 from intdata where xxx". You can get the count by "select count(trace1) from intdata where xxx". Use the same condition in order to get the same number of rows.
    Maybe another SQLExec object is needed to do the count.
    Whenever the datatable executes the SQL, the SQLExec executes and return the count.
    Ryan Shi
    National Instruments

  • Selection of a row in  a table

    Hi,
    I have a problem with JTable. ...i have just started working with JTables and still have not got a complete hang of how they function.
    I have a table whose model is "AbstractTableModel". I have different data in each row of the table therefore i have a celledtior and cell renderer per row. Each row is rendered as a combo box. There is only one column in that table. What i need to do is when the user clicks on any of these the rows in the table i need to evaluate what is the content in that row(in the combo box-It should be the values that have not been used up yet in the other rows...so basically as you add rows the combo box content will keep shrinking till all the possible vlaues are exhausted).
    I added a celleditor listener for every row. When the user clicks on the cell the event get's captured but the row value that shows up is not row the user selected. The value is always the previous selected row. Each cell is rendered as a combo box.
    For example if the user selected the first row in the table then the value of the row selected is -1. If the the user adds two more rows and selects the third row then the value selected is 0 (previos selected).
    What i cannot figure out is how in the world is this value obtained.
    Please help !! I tried everything i can think of to get the correct value of the row selected.
    Thanks a lot for your time and patience.
    Archana

    Hello Suman,
    Please, look at 'No First Select from Table' section of this blog: [/people/jarrod.williams/blog/2006/12/14/visual-composer-tips-and-tricks|/people/jarrod.williams/blog/2006/12/14/visual-composer-tips-and-tricks]
    Good luck,
    Ola

Maybe you are looking for