Using with and row_number in a query

I'm trying to do a sub-select on a top N type query, for multiple slices. It works for 1 or 2 slices at a time, but then returns nulls.
with subselect as
select issue, count(*) as cnt, row_number() over (order by count(*) desc) as rn
from TBL
group by issue
select * from
select avg(cnt) as avg1_10 from SUBSELECT
where rn between 1 and 10
select avg(cnt) as avg11_20 from SUBSELECT
where rn between 11 and 20
returns
AVG1_10 AVG11_20
140.5 100
This query works fine, and so does this.
with subselect as
select issue, count(*) as cnt, row_number() over (order by count(*) desc) as rn
from TBL
group by issue
select * from
select avg(cnt) from SUBSELECT
where rn between 21 and 30
select avg(cnt) from SUBSELECT
where rn between 31 and 40
AVG21_30 AVG31_40
70.6 59
but this query:
with subselect as
select issue, count(*) as cnt, row_number() over (order by count(*) desc) as rn
from TBL
group by issue
select * from
select avg(cnt) as avg1_10 from SUBSELECT
where rn between 1 and 10
select avg(cnt) as avg11_20 from SUBSELECT
where rn between 11 and 20
select avg(cnt) from SUBSELECT
where rn between 21 and 30
select avg(cnt) from SUBSELECT
where rn between 31 and 40
returns:
AVG1_10 AVG11_20 AVG21-30 AVG31-40
140.5 100
Does anyone have some insights?
Thank-you, CSW

The initial select returns hundreds of rows.
But I'm even more confused now. The following query
with subselect as
select * from (
select issue, count(*) as cnt, row_number() over (order by count(*) desc) as rn
from TBL
group by issue
)where rownum <= 100)
select * from
select avg(cnt) as avg1_10 from SUBSELECT
where rn between 1 and 10
select avg(cnt) as avg11_20 from SUBSELECT
where rn between 11 and 20
select avg(cnt) from SUBSELECT
where rn between 21 and 30
select avg(cnt) from SUBSELECT
where rn between 31 and 40
select avg(cnt) from SUBSELECT
where rn between 41 and 50
returns:
AVG1_10 AVG11_20 AVG21_30 AVG31_40 AVG41_50
140.5 100 70.6 59 50
Why would limiting the returning rows from the subselect affect the results?
Thanks.

Similar Messages

  • BO Explorer - using RKF and CKF of a query

    Hi,
    I am currently in the learning phase of Business Objects 4.1 tools and have some unanswered questions.
    I have recently started learning about the Explorer tool and was wondering whether there is a way I can use BEx queries as source in the Explorer tool. For now, I have created a relational data universe over the InfoCube using the Information Design Tool and used this new universe as a source in the Explorer tool but this did not bring in any of the existing BEx restricted key figures and calculated key figures.
    Are there any other ways I can connect directly to the BEx query directly to take advantage of the defined restricted key figure and calculated key figure. There are about 100 RKF and CKF over an InfoCube and I would really like to take advantage of the existing elements.
    I read through the discussion forums and found couple of different replies based on the version number.
    Please do guide me if you have resolved a similar issue. Thanks for reading.

    Ajay Gupta wrote:
    Grame,
         The relational method is the only option with Explorer.  You have other options when using WebI & Analysis for OLAP but NOT with Explorer.
    Regards,
    Ajay
    Thanks for the reply Ajay. I was following the below thread that mentions about creating universe using XI 3.1 and then using the constructed universe through Explorer. Is this available in BO 4.1, please do explain about this if possible.
    http://scn.sap.com/thread/3417905

  • Can AppleTV be used with and like Airtunes and Airport Express?

    So great! I can now play my music through my Home Cinema System on my TV but what about Airtunes? I have an Airport Express in my Studio and my Bedroom. Is there any way the Apple TV will act in the same way? Or can I select the other Airport Express Stations from AppleTV? If not are Apple planning on making this happen. I know it's early days for the AppleTV but they must have thought of this before hand? They did delay it's launch.
    Thanks in advance for comments and Help!
    Pete

    Currently there is no function to do that. I agree with you that this needs to be an added feature. Maybe the reasoning was that since the control for AirTunes is from the computer out to the remote speakers you would not need it with AppleTV since you control the content from there. Apple should have made the AppleTV not only a remote speaker but a remote controller. Maybe in the first update (PLEASE!).

  • How i use start with and rollup both in one query

    hi master
    sir i use rollup function for subtotal but rollup not give tree
    for tree i want to use start with and connect by function
    but that query give error
    sir how i use both rollup and start with connect by in one query
    for tree wise subtotal
    please give me idea
    thanking you

    hi master
    thank for your reply
    sir i get accid and title from master table and balance from detial table then system give me error
    sir i send me all table and data with query and error
    Sir this is my master table
    SQL> desc chartofacc;
    Name Null? Type
    PARENT NUMBER
    CHILD NUMBER
    ACCID NOT NULL VARCHAR2(15)
    TITLE VARCHAR2(99)
    CAMPID VARCHAR2(2)
    ACTIVE NUMBER
    FSTATUS NUMBER
    Data
    Parent child accid
         1     K1
    1     11     K11
    11     1101     K1101
    11     1102     K1102
    11     1103     K1103
    11     1104     K1104
    11     1105     K1105
    11     1106     K1106
    11     1107     K1107
    11     1108     K1108
    11     1109     K1109
    11     1110     K1110
    11     1111     K1111
    11     1112     K1112
    11     1113     K1113
    11     1114     K1114
    1     12     K12
    12     1201     K1201
    12     1202     K1202
    12     1203     K1203
    1     13     K13
    13     1301     K1301
    1301     130101     K130101
    1301     130102     K130102
    1301     130103     K130103
    1301     130104     K130104
    1301     130105     K130105
    1301     130106     K130106
    1301     130107     K130107
    1301     130108     K130108
    1301     130109     K130109
    1301     130110     K130110
    1301     130111     K130111
    1301     130112     K130112
    1301     130113     K130113
    1301     130114     K130114
    1301     130115     K130115
    13     1302     K1302
    1302     130201     K130201
    1302     130202     K130202
    1302     130203     K130203
    1302     130204     K130204
    1302     130205     K130205
    13     1303     K1303
    1303     130301     K130301
    1303     130302     K130302
    1303     130303     K130303
    13     1304     K1304
    1304     130401     K130401
    1304     130402     K130402
    1304     130403     K130403
    1304     130404     K130404
    1304     130405     K130405
    1304     130406     K130406
    1304     130407     K130407
    1304     130408     K130408
    13     1305     K1305
    1305     130501     K130501
    1305     130502     K130502
    13     1306     K1306
    1306     130601     K130601
    13     1307     K1307
    1307     130701     K130701
    1307     130702     K130702
    1307     130703     K130703
    1307     130704     K130704
    13     1308     K1308
    1308     130801     K130801
    1308     130802     K130802
    1308     130803     K130803
    1308     130804     K130804
    1308     130805     K130805
    1308     130806     K130806
    1308     130807     K130807
    1308     130808     K130808
    1308     130809     K130809
    1308     130810     K130810
    1308     130811     K130811
    1308     130812     K130812
    1308     130813     K130813
    13     1309     K1309
    13     1310     K1310
    13     1311     K1311
    1311     131101     K131101
         2     K2
    2     21     K21
    21     2101     K2101
    2101     210101     K210101
    2101     210102     K210102
    2101     210103     K210103
    2101     210104     K210104
    21     2102     K2102
    2102     210201     K210201
    2102     210202     K210202
    2102     210203     K210203
    2102     210204     K210204
    21     2103     K2103
    2103     210301     K210301
    2103     210302     K210302
    2103     210303     K210303
    2103     210304     K210304
    21     2104     K2104
    2104     210401     K210401
    2104     210402     K210402
    2104     210403     K210403
    2104     210404     K210404
    2     22     K22
    22     2201     K2201
    2201     220101     K220101
    2201     220102     K220102
    2201     220103     K220103
    2201     220104     K220104
    2201     220105     K220105
    22     2202     K2202
    2202     220201     K220201
    2202     220202     K220202
    2202     220203     K220203
    2202     220204     K220204
    22     2203     K2203
    2203     220301     K220301
    2203     220302     K220302
    2203     220303     K220303
    2203     220304     K220304
    22     2204     K2204
    2204     220401     K220401
    2204     220402     K220402
    2204     220403     K220403
    22     2205     K2205
    2205     220501     K220501
    2205     220502     K220502
    220502     22050201     K22050201
    220502     22050202     K22050202
    220502     22050203     K22050203
    220502     22050204     K22050204
    22     2206     K2206
    2206     220601     K220601
    2206     220602     K220602
    2206     220603     K220603
    2206     220604     K220604
    2     23     K23
    23     2301     K2301
    2301     230101     K230101
    2301     230102     K230102
    2301     230103     K230103
    2301     230104     K230104
    2301     230105     K230105
    2301     230106     K230106
    2301     230107     K230107
    2301     230108     K230108
    23     2302     K2302
    2302     230201     K230201
    2302     230202     K230202
    2302     230203     K230203
    2302     230204     K230204
    23     2303     K2303
    2303     230301     K230301
    2303     230302     K230302
    23     2304     K2304
    2304     230401     K230401
    2304     230402     K230402
    2304     230403     K230403
    23     2305     K2305
    2305     230501     K230501
    23     2306     K2306
    2306     230601     K230601
    2306     230602     K230602
    2306     230603     K230603
    2306     230604     K230604
    23     2307     K2307
    23     2308     K2308
    2308     230801     K230801
    2308     230802     K230802
    2308     230803     K230803
    23     2309     K2309
    2309     230901     K230901
    2309     230902     K230902
    2309     230903     K230903
    2309     230904     K230904
    23     2310     K2310
    2310     231001     K231001
    2310     231002     K231002
    2310     231003     K231003
    23     2311     K2311
    2311     231101     K231101
    2311     231102     K231102
    2311     231103     K231103
    23     2312     K2312
    2312     231201     K231201
    2312     231202     K231202
    2312     231203     K231203
    2312     231204     K231204
    23     2313     K2313
    2313     231301     K231301
    2313     231302     K231302
    2313     231303     K231303
    2313     231304     K231304
    2313     231305     K231305
    2313     231306     K231306
    2313     231307     K231307
    2313     231308     K231308
    2313     231309     K231309
    2313     231310     K231310
    2313     231311     K231311
    2313     231312     K231312
    2313     231313     K231313
    2313     231314     K231314
    2313     231315     K231315
    23     2314     K2314
    2314     231401     K231401
    2314     231402     K231402
    2314     231403     K231403
    2314     231404     K231404
    2314     231405     K231405
    2314     231406     K231406
    2314     231407     K231407
    23     2315     K2315
    23     2316     K2316
    2316     231601     K231601
    2316     231602     K231602
    23     2317     K2317
    23     2318     K2318
    23     2319     K2319
    2319     231901     K231901
    2319     231902     K231902
    2319     231903     K231903
    2319     231904     K231904
    2319     231905     K231905
    2319     231906     K231906
    23     2320     K2320
    2320     232001     K232001
         3     K3
    3     31     K31
    31     3101     K3101
    31     3102     K3102
    31     3103     K3103
    31     3104     K3104
    31     3105     K3105
    3     32     K32
    32     3201     K3201
    32     3202     K3202
    32     3203     K3203
    32     3204     K3204
    32     3205     K3205
    32     3206     K3206
    32     3207     K3207
         4     K4
    4     41     K41
    41     4101     K4101
    4101     410101     K410101
    4101     410102     K410102
    4101     410103     K410103
    4101     410104     K410104
    4101     410105     K410105
    4101     410106     K410106
    4101     410107     K410107
    4101     410108     K410108
    4101     410109     K410109
    4101     410110     K410110
    4101     410111     K410111
    4101     410112     K410112
    4101     410113     K410113
    4101     410114     K410114
    4101     410115     K410115
    4101     410116     K410116
    4101     410117     K410117
    4101     410118     K410118
    4101     410119     K410119
    4101     410120     K410120
    4101     410121     K410121
    4101     410122     K410122
    4101     410123     K410123
    4101     410124     K410124
    4101     410125     K410125
    4101     410126     K410126
    4101     410127     K410127
    4101     410128     K410128
    4101     410129     K410129
    4101     410130     K410130
    4101     410131     K410131
    4101     410132     K410132
    41     4102     K4102
    41     4103     K4103
    41     4104     K4104
    4104     410401     K410401
    4104     410402     K410402
    4104     410403     K410403
    4104     410404     K410404
    41     4105     K4105
    41     4106     K4106
    41     4107     K4107
    41     4108     K4108
    4108     410801     K410801
    4108     410802     K410802
    4108     410803     K410803
    41     4109     K4109
    4109     410901     K410901
    4109     410902     K410902
    4109     410903     K410903
    41     4110     K4110
    41     4111     K4111
    4111     411101     K411101
    4111     411102     K411102
    4111     411103     K411103
    41     4112     K4112
    4112     411201     K411201
    41     4113     K4113
    4113     411301     K411301
    41     4114     K4114
    4114     411401     K411401
    4114     411402     K411402
         5     K5
    5     51     K51
    51     5101     K5101
    51     5102     K5102
    51     5103     K5103
    51     5104     K5104
    51     5105     K5105
    51     5106     K5106
    51     5107     K5107
    51     5108     K5108
    51     5109     K5109
    51     5110     K5110
    51     5111     K5111
    51     5112     K5112
    51     5113     K5113
    51     5114     K5114
         6     K6
    6     61     K61
         7     K7
    7     71     K71
    7     72     K72
    7     73     K73
    7     74     K74
    7     75     K75
    7     76     K76
    This is my detil table
    SQL> desc accbal;
    Name Null? Type
    ACCID VARCHAR2(15)
    YEARID NUMBER
    CRBAL NUMBER
    DRBAL NUMBER
    ENTDATE DATE
    BALID NUMBER
    Data in detail
    K1101     46291132     
    K1102     13182173     
    K1103     23784045     
    K1107     10001795     
    K1108     9083529     
    K1110     4224350     
    K1112     6696832     
    K1113     7963381     
    K1114     742766     
    K1201     1486082     
    K130104     1977616     
    K130106     736266     
    K130107     396673     
    K130108     42751     
    K130109     298362     
    K130110     187696     
    K130111     537     
    K130112     942     
    K130113     987     
    K130114     1272     
    K130115     40000     
    K130205     259941     
    K130303     177716     
    K130406     809719     
    K130408     1786091     
    K130701     301000     
    K130702     151200     
    K130703     7570     
    K130704     34400     
    K1308          
    K130801     5400     
    K130802     45000     
    K130803     10856     
    K130807     24300     
    K130808     16500     
    K130810     104500     
    K130811     60000     
    K130812     181000     
    K130813     1750000     
    K1309     1225565     
    K1310     2176259     
    K1311          
    K131101     788780     
    K410101          24926
    K410102          9545
    K410103          28500
    K410104          8192
    K410105          847
    K410106          37100
    K410107          2332
    K410108          9844
    K410109          7843
    K410110          9313
    K410111          1425
    K410112          6089
    K410113          15497
    K410114          5790
    K410115          4251
    K410116          22293
    K410117          855
    K410118          6497
    K410119          14996
    K410120          124214
    K410121          6713
    K410122          1567
    K410123          75821
    K410124          5085
    K410125          7125
    K410126          4342
    K410127          21485
    K410128          641111
    K410129          589
    K410130          50
    K410131          163900
    K410132          3849
    K4105          3946489
    K4107          100000
    K410801          972011
    K410802          1707806
    K410803          116450
    K4110          13113874
    K411101          98335
    K411102          32454
    K411103          53569
    K411201          25327406
    K411301          7143103
    K411401          4500000
    K411402          12754
    K5102          2120031
    K5103          13543810
    K5107          4596103
    K5108          5604493
    K5110          2008401
    K5112          2182778
    K5113          4748537
    K5114          556914
    K61          43297680
    Sir I use this query
    select lpad(' ',2*(level-1)) || to_char(child),title,sum(drbal),sum(crbal),
    from chartofacc, accbal
    where chartofacc.accid=accbal.accid(+)
    start with parent is null
    connect by prior child = parent
    group by rollup(substr(mas.accid,2,1),substr(mas.accid,3,1),substr(mas.accid,4,2),substr(mas.accid,6,2) ,chartofacc.accid,title,fstatus);
    sir this query not give me result and give me error this
    SQL> /
    from chartofacc, accbal
    ERROR at line 2:
    ORA-00936: missing expression
    Please give me idea how I get tree type subtotal tribalance
    Thanking you
    Aamir

  • Query help needed for querybuilder to use with lcm cli

    Hi,
    I had set up several queries to run with the lcm cli in order to back up personal folders, inboxes, etc. to lcmbiar files to use as backups.  I have seen a few posts that are similar, but I have a specific question/concern.
    I just recently had to reference one of these back ups only to find it was incomplete.  Does the query used by the lcm cli also only pull the first 1000 rows? Is there a way to change this limit somwhere?
    Also, since when importing this lcmbiar file for something 'generic' like 'all personal folders', pulls in WAY too much stuff, is there a better way to limit this? I am open to suggestions, but it would almost be better if I could create individual lcmbiar output files on a per user basis.  This way, when/if I need to restore someone's personal folder contents, for example, I could find them by username and import just that lcmbiar file, as opposed to all 3000 of our users.  I am not quite sure how to accomplish this...
    Currently, with my limited windows scripting knowledge, I have set up a bat script to run each morning, that creates a 'runtime' properties file from a template, such that the lcmbiar file gets named uniquely for that day and its content.  Then I call the lcm_cli using the proper command.  The query within the properties file is currently very straightforward - select * from CI_INFOOBJECTS WHERE SI_ANCESTOR = 18.
    To do what I want to do...
    1) I'd first need a current list of usernames in a text file, that could be read (?) in and parsed to single out each user (remember we are talking about 3000) - not sure the best way to get this.
    2) Then instead of just updating the the lcmbiar file name with a unique name as I do currently, I would also update the query (which would be different altogether):  SELECT * from CI_INFOOBJECTS where SI_OWNER = '<username>' AND SI_ANCESTOR = 18.
    In theory, that would grab everything owned by that user in their personal folder - right? and write it to its own lcmbiar file to a location I specify.
    I just think chunking something like this is more effective and BO has no built in back up capability that already does this.  We are on BO 4.0 SP7 right now, move to 4.1 SP4 over the summer.
    Any thoughts on this would be much appreciated.
    thanks,
    Missy

    Just wanted to pass along that SAP Support pointed me to KBA 1969259 which had some good example queries in it (they were helping me with a concern I had over the lcmbiar file output, not with query design).  I was able to tweak one of the sample queries in this KBA to give me more of what I was after...
    SELECT TOP 10000 static, relationships, SI_PARENT_FOLDER_CUID, SI_OWNER, SI_PATH FROM CI_INFOOBJECTS,CI_APPOBJECTS,CI_SYSTEMOBJECTS WHERE (DESCENDENTS ("si_name='Folder Hierarchy'","si_name='<username>'"))
    This exports inboxes, personal folders, categories, and roles, which is more than I was after, but still necessary to back up.. so in a way, it is actually better because I have one lcmbiar file per user - contains all their 'personal' objects.
    So between narrowing down my set of users to only those who actually have saved things to their personal folder and now having a query that actually returns what I expect it to return, along with the help below for a job to clean up these excessive amounts of promotion jobs I am now creating... I am all set!
    Hopefully this can help someone else too!
    Thanks,
    missy

  • Using join and batch reading in the same query

    Hi,
    I wonder if it is possible to use "Joining" and "batch reading" in the same query.
    For example I Have
    A -> 1-1 B
    A -> 1-1 B
    B -> 1-M C
    This is the case where I have two separate 1-1 relationships to the same class B from A. Toplink 10.0.3 can manage it nicely through joining.
    Now, I would like to read a set of As (with its 2 Bs) and all Cs for each B.
    It seems that the following configuration does not work:
    A -> 1-1 B (use joining)
    A -> 1-1 B (use joining)
    B -> 1-M C (Batch read)
    Any help would be greatly appreciated
    Tony.

    James,
    Would you be so kind to look at the following code?
    Am I formulating it correctly to achieve my desired behavior?
    Trip.class -> 1-1 PickupStop
    Trip.class -> 1-1 DropoffStop
    PickupStop and DropoffStop extend Stop and use same table (STOP)
    Stop -> 1-M StopEvents
    I would like to fetch all Trips, with their Stops and all StopEvents in 2 queries:
    1. Trip joined with Stop
    2. Batchread StopEvents
    Code:
    ReadAllQuery raq = new ReadAllQuery(Trip.class);
    Expression qexp1 = new ExpressionBuilder();
    Expression qexp2 = new ExpressionBuilder();
    raq.addJoinedAttribute("pickupStop");
    raq.addJoinedAttribute("dropoffStop");
    raq.addBatchReadAttribute(qexp1.get("pickupStop").get("vStopEvents"));
    raq.addBatchReadAttribute(qexp2.get("dropoffStop").get("vStopEvents"));

  • I Have iPad4 and using with Aricel Prepaid 3G SIM, How to check my VAlidity period and balance amount through iPad?. pls help me

    I Have iPad4 and using with Aricel Prepaid 3G SIM, How to check my VAlidity period and balance amount through iPad?. pls help me, M.Kumar, Chennai,
    <Email Edited By Host>

    There are 2 concepts attached to a bank balance. The balance as per your books of accounts and another is the balance maintained with the bank. I believe i need not explain these 2 concepts. These 2 balances can be obtained from Oracle system provided some of prerequsities are met with.
    Balance as per your books - This is nothing but the GL balance available. In order to obtain balances for each bank accounts, it is advised that each bank account should have a separate account code combination. This is achieved generally by having a separate natural account for each bank. The code combination is attached to the cahs account for each bank. By maintaining separate account code combination, the balance in each code combination can be obtained from GL (provided transactions are accounted and posted in GL). These balances represent the balance for each bank according to your books of accounts. You can create an FSG for this purpose and provide the same to the customer, so that they can run the same whenevr they want.
    Balance as per bank - This balance is maintained by oracle in 2 ways - either the bank balance can be manually entered for each bank account for each date (quite cumbersome). Else, while loading the bank statement, the bank balances are also loaded. There are various types of bank balances stored - value dated balance, available balance, float balance etc. Depending on the balances provided by bank along with the bank statement, the bank balance can be recorded in oracle system. After the bank statement is uploaded and balances stored, standard cash management reports are available to query for the bank account balances. In order to view daily movement, the bank statement should be loaded on daily basis.
    Hope this helps.
    Vinit

  • Please help how to use WITH query in UPDATE

    Hi Experts,
    Please help me.
    Thanks.

    Not sure about your required output. But try using WITH clause query inside SET clause of UPDATE statement.
       UPDATE SALES_REVENUE SR
        SET
                 (SR.TODAY_REV,
                 SR.TODAY_MARGIN,
                 SR.TODAY_UNIT
                 ) =
    (WITH result_sum_temp
    AS(
        SELECT SALE_ID, IN_TEAM, 1 SALE_FLAG, loc, seg,
            SUM(REV * rate) AS sum_rev,
            SUM(MARGIN * rate) AS sum_mar,
            SUM(UNIT) AS SUM_UNIT
        FROM SALES
        WHERE (IGNORED IS NULL OR IGNORED <> 'Y')
        AND SALE_SPOT = 7
        AND SALE_ID = 375
        AND SALE_MODEL = 'D'
        AND IN_TEAM IS NOT NULL AND loc IS NOT NULL
        GROUP BY SALE_ID, IN_TEAM, loc, seg
         UNION ALL
        SELECT SALE_ID, OUT_TEAM, 2 SALE_FLAG, loc, seg,
            SUM(REV * rate) AS sum_rev,
            SUM(MARGIN * rate) AS sum_mar,
            SUM(UNIT) AS SUM_UNIT
        FROM SALES
        WHERE (IGNORED IS NULL OR IGNORED <> 'Y')
        AND SALE_SPOT = 2
        AND SALE_ID = 375
        AND SALE_MODEL = 'D'
        AND OUT_TEAM IS NOT NULL AND loc IS NOT NULL
        GROUP BY SALE_ID, OUT_TEAM, loc, seg)
                    (SELECT   t.sum_rev, t.sum_mar, t.sum_unit
                       FROM   result_sum_temp t
                      WHERE       SR.SALE_ID = t.SALE_ID
                              AND SR.team_id = t.team_id
                              AND SR.SALE_FLAG = t.SALE_FLAG
                              AND SR.SEG = t.seg
                              AND SR.loc = t.loc
                              AND t.SALE_ID = 255)
        WHERE   SR.SALE_SPOT = 890
                AND SR.SALE_ID = 255
                AND (SR.SALE_ID, SR.team_id, SR.sale_flag, SR.SEGMENT, SR.LOB) IN
                          (SELECT   SALE_ID,
                                    team_id,
                                    sale_flag,
                                    seg,
                                    loc
                             FROM   result_sum_temp));

  • An index can not being used and still afect a query performance?

    Hi i have a query with a high cost so i created two indexes, A and B, to improve its performance.
    After the creation of the indexes when i reviewed the execution plan of the query the cost had been reduced, but i noticed that the index B is not being used,
    and if i try to force the query to use index B with a HINT the cost increases, so i decided to drop the index B.
    Once i droped the index B i checked the execution plan again and then i noticed that the cost of the query increased, if i recreate the index B the explain plan
    shows a lower cost even though its not being used by the execution plan.
    Does anyone know why is this happening?
    An index can, not being used by the execution plan and still affect a query performance?

    user11173393 wrote:
    Hi i have a query with a high cost so i created two indexes, A and B, to improve its performance.
    After the creation of the indexes when i reviewed the execution plan of the query the cost had been reduced, but i noticed that the index B is not being used,
    and if i try to force the query to use index B with a HINT the cost increases, so i decided to drop the index B.
    Once i droped the index B i checked the execution plan again and then i noticed that the cost of the query increased, if i recreate the index B the explain plan
    shows a lower cost even though its not being used by the execution plan.
    Does anyone know why is this happening?
    An index can, not being used by the execution plan and still affect a query performance?You said that is what is happening, & I believe you.

  • Using START WITH and CONNECT BY PRIOR in a report

    Hi - I am using Oracle 9i and reports 10g. Does anyone know of a reason why running my sql in TOAD will produce the correct results, but the report is dropping records? I am using start with and connect by prior to build a hierarchy of linked records. The report is dropping the "child records" and only returning records from the route level.
    Thanks you for your help.

    Hi user574499
    Could u pls share us ur Query...?
    Regards,
    Abdetu...

  • SQL query with AND or OR

    Hi,
    I am trying to get a recordset that samples multiple columns of my Access database for filtering, rather than just one.  I looked at a few .asp websites and they say the query would be written like this:
    SELECT SystemName, SystemCategory, Branch, Manufacturer
    FROM UnmmannedAircraftSystems
    WHERE Branch LIKE %MMColParam%
    AND PerfSensorPayloads LIKE %MMColParam2%
    ORDER BY SystemName ASC
    but it never works.  The page fails on the server.  And I know this type of query works through straight .asp coding, but somehow the way Dreamweaver sets up the variables is killing it.
    Anybody have an ideas?
    MW

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    <!--#include file="../../Connections/BleahBleahBleahhhhh" -->
    <%
    Dim RSfilterRec__MMColParam
    RSfilterRec__MMColParam = "1"
    If (Request.Form("BranchesUsedby") <> "") Then
      RSfilterRec__MMColParam = Request.Form("BranchesUsedby")
    End If
    %>
    <%
    Dim RSfilterRec__MMColParam2
    RSfilterRec__MMColParam2 = "1"
    If (Request.Form("SensorPay") <> "") Then
      RSfilterRec__MMColParam2 = Request.Form("SensorPay")
    End If
    %>
    <%
    Dim RSfilterRec
    Dim RSfilterRec_cmd
    Dim RSfilterRec_numRows
    Set RSfilterRec_cmd = Server.CreateObject ("ADODB.Command")
    RSfilterRec_cmd.ActiveConnection = MM_ConnUASdata_STRING
    RSfilterRec_cmd.CommandText = "SELECT SystemName, SystemCategory, Branch, Manufacturer FROM UnmannedAircraftSystems WHERE Branch LIKE ? AND PerfSensorsPayloads LIKE ? ORDER BY SystemName ASC"
    RSfilterRec_cmd.Prepared = true
    RSfilterRec_cmd.Parameters.Append RSfilterRec_cmd.CreateParameter("param1", 200, 1, 255, "%" + RSfilterRec__MMColParam + "%") ' adVarChar
    RSfilterRec_cmd.Parameters.Append RSfilterRec_cmd.CreateParameter("param2", 200, 1, 255, "%" + RSfilterRec__MMColParam2 + "%") ' adVarChar
    Set RSfilterRec = RSfilterRec_cmd.Execute
    RSfilterRec_numRows = 0
    %>
    <%
    Dim Repeat1__numRows
    Dim Repeat1__index
    Repeat1__numRows = 10
    Repeat1__index = 0
    RSfilterRec_numRows = RSfilterRec_numRows + Repeat1__numRows
    %>
    <!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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!-- TemplateBeginEditable name="doctitle" -->
    <title>Untitled Document</title>
    <!-- TemplateEndEditable -->
    <!-- TemplateBeginEditable name="head" -->
    <!-- TemplateEndEditable -->
    <style type="text/css">
    <!--
    body  {
    font: 100% Verdana, Arial, Helvetica, sans-serif;
    background: #666666;
    margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
    padding: 0;
    text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
    color: #000000;
    /* Tips for Elastic layouts
    1. Since the elastic layouts overall sizing is based on the user's default fonts size, they are more unpredictable. Used correctly, they are also more accessible for those that need larger fonts size since the line length remains proportionate.
    2. Sizing of divs in this layout are based on the 100% font size in the body element. If you decrease the text size overall by using a font-size: 80% on the body element or the #container, remember that the entire layout will downsize proportionately. You may want to increase the widths of the various divs to compensate for this.
    3. If font sizing is changed in differing amounts on each div instead of on the overall design (ie: #sidebar1 is given a 70% font size and #mainContent is given an 85% font size), this will proportionately change each of the divs overall size. You may want to adjust based on your final font sizing.
    .thrColEls #container {
    width: 46em;  /* this width will create a container that will fit in an 800px browser window if text is left at browser default font sizes */
    background: #FFFFFF;
    margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
    border: 1px solid #000000;
    text-align: left; /* this overrides the text-align: center on the body element. */
    /* Tips for sidebar1:
    1. Be aware that if you set a font-size value on this div, the overall width of the div will be adjusted accordingly.
    2. Since we are working in ems, it's best not to use padding on the sidebar itself. It will be added to the width for standards compliant browsers creating an unknown actual width.
    3. Space between the side of the div and the elements within it can be created by placing a left and right margin on those elements as seen in the ".thrColEls #sidebar1 p" rule.
    .thrColEls #sidebar1 {
    float: left;
    width: 11em; /* since this element is floated, a width must be given */
    background: #EBEBEB; /* top and bottom padding create visual space within this div */
    height: 1200px;
    padding-top: 15px;
    padding-right: 0;
    padding-bottom: 15px;
    padding-left: 0;
    .thrColEls #sidebar2 {
    float: right;
    width: 11em; /* since this element is floated, a width must be given */
    background: #EBEBEB; /* the background color will be displayed for the length of the content in the column, but no further */
    padding: 15px 0; /* top and bottom padding create visual space within this div */
    height: 1200px;
    .thrColEls #sidebar1 h3, .thrColEls #sidebar1 p, .thrColEls #sidebar2 p, .thrColEls #sidebar2 h3 {
    margin-left: 10px; /* the left and right margin should be given to every element that will be placed in the side columns */
    margin-right: 10px;
    height: 100%;
    /* Tips for mainContent:
    1. If you give this #mainContent div a font-size value different than the #sidebar1 div, the margins of the #mainContent div will be based on its font-size and the width of the #sidebar1 div will be based on its font-size. You may wish to adjust the values of these divs.
    2. The space between the mainContent and sidebar1 is created with the left margin on the mainContent div.  No matter how much content the sidebar1 div contains, the column space will remain. You can remove this left margin if you want the #mainContent div's text to fill the #sidebar1 space when the content in #sidebar1 ends.
    3. To avoid float drop, you may need to test to determine the approximate maximum image/element size since this layout is based on the user's font sizing combined with the values you set. However, if the user has their browser font size set lower than normal, less space will be available in the #mainContent div than you may see on testing.
    4. In the Internet Explorer Conditional Comment below, the zoom property is used to give the mainContent "hasLayout." This avoids several IE-specific bugs that may occur.
    .thrColEls #mainContent {
      margin: 0 12em 0 12em; /* the right margin can be given in ems or pixels. It creates the space down the right side of the page. */
    /* Miscellaneous classes for reuse */
    .fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
    float: right;
    margin-left: 8px;
    .fltlft { /* this class can be used to float an element left in your page */
    float: left;
    margin-right: 8px;
    .clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain a float */
    clear:both;
        height:0;
        font-size: 1px;
        line-height: 0px;
    -->
    </style><!--[if IE]>
    <style type="text/css">
    /* place css fixes for all versions of IE in this conditional comment */
    .thrColEls #sidebar1, .thrColEls #sidebar2 { padding-top: 30px; }
    .thrColEls #mainContent { zoom: 1; padding-top: 15px; }
    /* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
    </style>
    <![endif]--></head>
    <body class="thrColEls">
    <div id="container">
      <div id="sidebar1">
        <h3> </h3>
        <!-- end #sidebar1 --></div>
      <div id="sidebar2">
        <h3> </h3>
        <!-- end #sidebar2 --></div>
      <div id="mainContent">
        <h1> 
          <table border="1">
            <tr>
              <td>ID</td>
              <td>SystemName</td>
              <td>SystemCategory</td>
              <td>Branch</td>
              <td>Manufacturer</td>
              <td>Status</td>
              <td>Inventory</td>
              <td>PlatformCost</td>
              <td>SystemCost</td>
              <td>PlannedBuyToDate</td>
              <td>PlannedBuyYear1</td>
              <td>PlannedBuyYear1Quantity</td>
              <td>PlannedBuyYear2</td>
              <td>PlannedBuyYear2Quantity</td>
              <td>PlannedBuyYear3</td>
              <td>PlannedBuyYear3Quantity</td>
              <td>PlannedBuyYear4</td>
              <td>PlannedBuyYear4Quantity</td>
              <td>PlannedBuyYear5</td>
              <td>PlannedBuyYear5Quantity</td>
              <td>PlannedBuyYear6</td>
              <td>PlannedBuyYear6Quantity</td>
              <td>PlannedBuyYear7</td>
              <td>PlannedBuyYear7Quantity</td>
              <td>PlannedBuyYear8</td>
              <td>PlannedBuyYear8Quantity</td>
              <td>PlaformOperationPicLink</td>
              <td>OrthoDrawingLink</td>
              <td>Capability</td>
              <td>BackgroundSysDescrip</td>
              <td>SystemDescription</td>
              <td>CharLength</td>
              <td>CharWingSpan</td>
              <td>CharGrossWgt</td>
              <td>CharPayloadWgt</td>
              <td>CharEngines</td>
              <td>CharFuelWgtType</td>
              <td>DataLinks1</td>
              <td>DataLinks2</td>
              <td>DataLinks3</td>
              <td>Frequencies1</td>
              <td>Frequencies2</td>
              <td>Frequencies3</td>
              <td>PerfEndurance</td>
              <td>PerfRadius</td>
              <td>PerfCeiling</td>
              <td>PerfAirspeeds</td>
              <td>PerfTakeoff</td>
              <td>PerfLanding</td>
              <td>PerfSensorsPayloads</td>
              <td>PerfSensorModels</td>
              <td>PayloadCharInternalSize</td>
              <td>PayloadCharInternalWgt</td>
              <td>PayloadCharInternalPwr</td>
              <td>PayloadCharInternalEnv</td>
              <td>PayloadCharExternalSize</td>
              <td>PayloadCharExternalWgt</td>
              <td>PayloadCharExternalPwr</td>
              <td>PayloadCharExternalEnv</td>
            </tr>
            <% While ((Repeat1__numRows <> 0) AND (NOT RSfilterRec.EOF)) %>
              <tr>
                <td><%=(RSfilterRec.Fields.Item("ID").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("SystemName").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("SystemCategory").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("Branch").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("Manufacturer").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("Status").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("Inventory").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PlatformCost").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("SystemCost").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PlannedBuyToDate").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PlannedBuyYear1").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PlannedBuyYear1Quantity").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PlannedBuyYear2").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PlannedBuyYear2Quantity").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PlannedBuyYear3").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PlannedBuyYear3Quantity").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PlannedBuyYear4").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PlannedBuyYear4Quantity").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PlannedBuyYear5").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PlannedBuyYear5Quantity").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PlannedBuyYear6").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PlannedBuyYear6Quantity").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PlannedBuyYear7").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PlannedBuyYear7Quantity").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PlannedBuyYear8").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PlannedBuyYear8Quantity").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PlaformOperationPicLink").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("OrthoDrawingLink").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("Capability").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("BackgroundSysDescrip").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("SystemDescription").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("CharLength").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("CharWingSpan").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("CharGrossWgt").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("CharPayloadWgt").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("CharEngines").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("CharFuelWgtType").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("DataLinks1").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("DataLinks2").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("DataLinks3").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("Frequencies1").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("Frequencies2").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("Frequencies3").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PerfEndurance").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PerfRadius").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PerfCeiling").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PerfAirspeeds").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PerfTakeoff").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PerfLanding").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PerfSensorsPayloads").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PerfSensorModels").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PayloadCharInternalSize").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PayloadCharInternalWgt").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PayloadCharInternalPwr").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PayloadCharInternalEnv").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PayloadCharExternalSize").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PayloadCharExternalWgt").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PayloadCharExternalPwr").Value)%></td>
                <td><%=(RSfilterRec.Fields.Item("PayloadCharExternalEnv").Value)%></td>
              </tr>
              <%
      Repeat1__index=Repeat1__index+1
      Repeat1__numRows=Repeat1__numRows-1
      RSfilterRec.MoveNext()
    Wend
    %>
          </table>
        </h1>
        <!-- end #mainContent --></div>
    <!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat" />
    <!-- end #container --></div>
    </body>
    </html>
    <%
    RSfilterRec.Close()
    Set RSfilterRec = Nothing
    %>

  • When to go for generic extraction using view and infoset query?

    Hi,
                        Can anyone clarify me when we should go for generic extraction using view and when we should go for generic extraction using infoset query....
    Also what is the difference between view and infoset?
    I tried but could not find out....
    Regards,
    Kalyani.

    Hi Kalyani,
    We normally go for View or infoset when the data to be fetched in BW is distributed in different tables in SAP R/3.
    Had the data been available in one table we can easily build our datasource on that table but if there are more tables then its not possible to do it without Views or Infosets. You can use Function Modules to build your datasource in case it involves complex logic to figure out the data from various tables.
    Depending upon the table relationships we create view and include various fields from these tables in that view. Same is with the Infosets, you can have more flexible options like Outer Join, left outer Join etc.
    Regards,
    Pratap Sone

  • How to tack print out use with Query ?

    Hi
    I have to tack purchase order print out (print details- PO date, BP code, name, item name, Quantity and Amount . System Print Layout means from Purchase Order layout designer) use with Query
    How to tack print out use with Query (system print layout means from  Purchase Order layout designer) ?
    Regards
    Aravind M

    Hi
    I have to take purchase order print out and I created 3 templates for that purchase order in layout designer (Because as per the MIS requirement I created 3 templates, its cover more information). I have to take print out 3 templates at a time. So i try to take print use with Query.
    Regards
    Aravind M

  • Error erase Queries in Query Manager- The query is used with user-define...

    Hello Experts
    I have deleted a User Field that had a Formatted Search and now I can not remove it because it is linked according to a UF, the error message is as follows:
    "The query is used with user-defined values [Message 952-23]"
    There will be a way to resolve this issue???
    Thanks in advance

    Hi Juan,
    I have tried this very limited, but the formid, is this a number in your case?
    SELECT * from cshs t0 inner join ouqr t1 on t0.queryid = t1.intrnalkey
    where t1.qname = '[%0]'
    Running this query I can get the form id that I need to recreate, but I have a feeling you already know the form id, is this correct?
    - Is there an error when you try to recreate the form id?
    - Will it not let you recreate the same form id because the id is given by the system?
    If it is not possible to recreate the form id, please prepare a backup and log a message. Support should be able to correct the entry in table cshs.
    Hope it helps.
    Jesper

  • Using ConnBean and CursorBean with a Data Source

    Hi all,
    I',m making a web app. using the Jdev (RUP4) with OA Extension. I looked in the help menu under "About Data-Access JavaBeans and Tags". Here I found the following example, but for some stange reason I cannot get the setProperty to work.
    Example: Using ConnBean and CursorBean with a Data Source This following is a sample JSP page that uses ConnBean with a data source to open a connection, then uses CursorBean to execute a query.
    <%@ page import="java.sql.*, oracle.jsp.dbutil.*" %>
    <jsp:useBean id="cbean" class="oracle.jsp.dbutil.ConnBean" scope="session">
    <jsp:setProperty name="cbean" property="dataSource"
    value="<%=request.getParameter("datasource")%>"/>
    </jsp:useBean>
    <% try {
    cbean.connect();
    String sql="SELECT ename, sal FROM scott.emp ORDER BY ename";
    CursorBean cb = cbean.getCursorBean (CursorBean.PREP_STMT, sql);
    out.println(cb.getResultAsHTMLTable());
    cb.close();
    cbean.close();
    } catch (SQLException e) {
    out.println("<P>" + "There was an error doing the query:");
    out.println("<PRE>" + e + "</PRE>\n<P>"); }
    %>
    Does anyone know how to set the "Property" to a datasource and make it work?
    Best regards,
    MHCI

    There is no point-and-click (Import Data Source Metadata) way to use an LDAP server as a datasource. You have to use the Java Function provided on dev2dev. If you need help with it, please post here.
    - Mike

Maybe you are looking for