Want to differentiate the queries

I have the Master Table
PARTS
TotalSize ----- TotalPrice
147          12.5
In the Query,
I will get the details of the Subcategory
Id -- 12
Size - 295 [147+148]
price -- 10.3
Iwant to check the TotalSize and TotalPrice from the Master Table and need to show it in the different
parts.....For example
PART-1
147
PART-2
147
PART-3
1
How can do this please help..............

<
TABLE-1 [Master Table]
ID -- TOTALSIZE -- TOTALSUBCOUNT
1 -- 1000 -- 356487
TABLE-2
ID--USERID--NAME--DESC
1--1--TEST--TEST
2--1--DUMMY--DUMMY
3--2--TRY--TRY
TABLE-3
ID--TABLE_2_ID--SIZE
1--1--252]
2--1--265]--- TOTAL SIZE - 1082 Comparing it with the Master Table TOTALSIZE - 1000
3--1--565]
4--2--225
Now i want to get the COUNT(TABLE_2_ID)FROM TABLE-3,SUM(SIZE) WITH AN ADDITIONAL FIELD AS PARTS...
For Example i want to list as follows
NAME --- COUNT -- PARTS
TEST--3-- PART-1 -- THE CAPACITY TO HOLD TOTALSIZE IS 1000
TEST--3-- PART-2 -- THE REMAINING 82 WILL BE HOLD IN THE NEXT PART,PARTS-2
This what i exactly need,think u all will understand i need...
Help me in this
>
/*********** Response from Nicolas ***********/
<
Re: Want to differentiate the queries
Posted: Jan 9, 2007 1:35 AM in response to: Rob van Wijk Reply
Rob,
That doesn't work in case of the sum of isize (table_3) is more than 2000 :
SQL> select name 2 , count_id as "COUNT" 3 , 'PART' || g as "PART" 4 , case last_value(g) over (partition by id) 5 when 1 then sum_size 6 when 2 then case g when 1 then 1000 else sum_size - 1000 end 7 end as "PARTSIZE" 8 from ( select table_1.id 9 , table_1.totalsize 10 , table_2.name 11 , case when sum(isize) over (partition by table_1.id order by table_3.id) <= 1000 then 1 else 2 end g 12 , sum(isize) over (partition by table_1.id) sum_size 13 , count(table_1.id) over (partition by table_1.id) count_id 14 from table_1 15 , table_2 16 , table_3 17 where table_3.table_2_id = table_2.id 18 and table_2.id = table_1.id 19 ) 20 group by g 21 , id 22 , name 23 , count_id 24 , sum_size 25 /NAME COUNT PART PARTSIZE----- ---------- -------------------------------------------- ----------TEST 5 PART1 1000TEST 5 PART2 1842SQL>
Maybe there is a better way, but here a try :
SQL> drop table tbl1;Table dropped.SQL> create table tbl1 as 2 select 1 id, 1000 totalsize, 356487 totalsubcount from dual union all 3 select 2, 1000, 0 from dual ;Table created.SQL> SQL> drop table tbl2 ;Table dropped.SQL> create table tbl2 as 2 select 1 id, 1 userid, 'TEST' name, 'TEST' cdesc from dual union all 3 select 2, 1, 'DUMMY', 'DUMMY' from dual union all 4 select 3, 2, 'TRY', 'TRY' from dual;Table created.SQL> SQL> drop table tbl3;Table dropped.SQL> create table tbl3 as 2 select 1 id, 1 tbl2_id, 252 csize from dual union all 3 select 2, 1, 265 from dual union all 4 select 3, 1, 1665 from dual union all 5 select 4, 2, 1000 from dual union all 6 select 5, 3, 0 from dual;Table created.SQL> SQL> select distinct part, totalsize, name, tbl2_id, csize 2 from (select level lv,'PART'||level as part, totalsize, name, tbl2_id, 3 case when csize-(level*totalsize) < 0 then csize-((level-1)*totalsize) 4 else totalsize end csize 5 from (select a.totalsize, b.name, c.tbl2_id, sum(c.csize) csize 6 from tbl1 a, tbl2 b, tbl3 c 7 where c.tbl2_id=b.id 8 and b.userid=a.id 9 group by a.totalsize, b.name, c.tbl2_id) 10 connect by level <= ceil(csize/totalsize)) 11 order by 3,1 12 /PART TOTALSIZE NAME TBL2_ID CSIZE-------------------------------------------- ---------- ----- ---------- ----------PART1 1000 DUMMY 2 1000PART1 1000 TEST 1 1000PART2 1000 TEST 1 1000PART3 1000 TEST 1 182PART1 1000 TRY 3 0SQL>
Nicolas.
>
<
Nicolas,
Just now noticed clearly that
SQL> select distinct part, totalsize, name, tbl2_id, csize 2 from (select level lv,'PART'||level as part, totalsize, name, tbl2_id, 3 case when csize-(level*totalsize) < 0 then csize-((level-1)*totalsize) 4 else totalsize end csize 5 from (select a.totalsize, b.name, c.tbl2_id, sum(c.csize) csize 6 from tbl1 a, tbl2 b, tbl3 c 7 where c.tbl2_id=b.id 8 and b.userid=a.id 9 group by a.totalsize, b.name, c.tbl2_id) 10 connect by level <= ceil(csize/totalsize)) 11 order by 3,1
the above query is not working for me
>
Please help me in this.....
I once again tell u clearly what i need.
I need the csize,totalsubcount,COUNT(table_2.id),PARTS
The relationship between the tables are
TABLE_1 is not related to other two tables........ [just i want to check the totalsize and totalsubcount from that table]
TABLE_2 [table2_id PK]
TABLE_3 [TABLE_3.table2_id reference to the TABLE_2(table_2_id)]
Please help me in this.....
Thanks in Advance
Symon

Similar Messages

  • How to narrow down the queries regards to specific needs?

    Hi All,
    I have 100s of queries, and I want to find the queries which use only specific object name, for example, 0comp_code, how do I do that?
    Thanks!

    Hi,
    Go to RSA1, select your infoobject by double clicking on it.  Click on the "where used" button, it will display all objects where it is used and queries will be one node.
    Cheers.

  • HT1918 2 daugheters received an iPad. Both are on my iTunes account. How to differentiate the two devices in the Game Center?

    So my two daughters (aged 7 & 9) each received an iPad for Christmas.  They are interested in the same games and I installed them on their device.  Because I registered both of their iPads on my iTunes account, when play these games they are "me".  I would like to differentiate the two so they are each playing their own account.  Do I need to create seperate iTunes accounts for them?  If I do that, I can't install the apps that I have already bought.  There must be a way!  Any help would be appreciated.

    The reason you are receiving each other's text messages is because you are both using the same Apple ID for iMessage.  To prevent this you need to use different IDs.  (Note: you can still share the same ID for iTunes.)  On one of the phones, go to Settings>Messages>Send & Receive, tap the ID, sign out, then sign back in with a separate ID.
    To migrate your 3GS to a new iCloud account, start by saving any photo stream photos that you want to keep on the phone to your camera roll.  To do this, open the my photo stream album, tap Edit, tap the photos, tap Share, tap Save to Camera Roll.  Next, if you have any notes that you are syncing with iCloud that you want to keep, you'll need to email these to yourself so they can be recreated after moving to the new account.
    Once this is done, go to Settings>iCloud, scroll to the bottom and tap Delete Account.  (This will only delete the account from this phone, not from iCloud.  The phone that will be keeping the account will not be effected by this.)  When prompted about what to do with the iCloud data, choose Keep On My iPhone.  Next, sign back in with a different Apple ID to create the new account, turn iCloud data syncing preferences and when prompted about merging with iCloud, choose Merge.  This will upload the data to the new account.
    Finally, if you have merged data in the two accounts that you want to separate you will have to go to icloud.com from your computer, sign into each iCloud account separately and manually delete the data you don't want from each account.

  • How to delete the queries in  BW Production which are no longer existing.

    Hi,
    How to  delete the queries in BW production which are no longer existing in DEV.
    1. I tried Using RSZDELETE in Production it is not getting deleted and the below message given.
    Query object 4A7V83T3RB4ABIOKSDJT2HWDL is blocked. Deletion has been cancelled.
    2. I tried creating another query in dev with the same technical name and send a transport with deletion
    it is not working.
    Please advise me on this for any function module or any other method.
    Thanks
    Surya

    Hi,
    If you transported the query from DEV and now you want to delete it, you should open a BEx request (Dev Class under which it was originally transported -- or-- Standard - type) in DEV delete the query and move the transport to Production.
    As far as your error is concerned, usually  when you  can delete a query using the delete option in query designer itself,
    Business Explorer> query-> delete objects , when you press execute the system offers you a list of dependent objects on the query(workbook,views), in case the sysytem is unable to delete them i.e.they being used as a input query for a characteristic variable (replacement path),then system throws this error.You can delete these all depndents under there prescribed roles , fav s & then proceed.
    Hope this will be expedite.
    Thax & regards.
    Vaibhave Sharma

  • While running the query how much time it will taken, I want to see the time

    Hi Folks
    I would like to know ... While running the query how much time it will be taken, I want to see the time? in WEBI XI R2.....
    Plz let me know  the answer.......

    Hi Ravi,
    The time a report runs is estimated based on the last time it was run. So you need to run the report once before you can see how long it will take. Also it depends on several factors... the database server could cache some queries so running it a second time immediately after the first time could be quicker. And there is the chance of changing filters to bring back different sets of data.
    You could also schedule a report and then check the scheduled instance's status properties and view how long a report actually ran.
    Good luck

  • Requirement wherein I want to call two queries in parallel using ABAP Prg

    We are using RSCRM_BAPI to run a query in background and write the results to a table. We later read this table and create a file. I have a requirement u2013 wherein I want to call two queries in parallel using an ABAP program.
    For our discussion assume:
    1) Program : ZCALL_RCRMBAPI  is a program that calls RSCRM_BAPI in background and takes the query name as input
    2) Program: ZMAIN_PROGRAM  this is the main program
    The requirement is to call the ZCALL_RCRMBAPI in a loop. Also within the loop call it in parallel. Basically we have an ODS that stores ; FISCPER. So I call the two queries for a list of FISCPER.
    ZMAIN_PROGRAM - A program that reads a table (ODS ) in our case and call the two programs in a loop and both should run in parallel .
    Now if it was sequential u2013 it was easy u2013 I would just say
    Loop at L_T_FISCPER .
    Update Z_FISCPER with L_T_FISCPER-FISCPER u201C Assume Z_FISCPER is a Z table . The VARIABLE in the query Q1 and Q2 use a customer exit to read this table.
    A)       SUBMIT ZCALL_RCRMBAPI with P_QUERy = Q1 and return .
    B)      SUBMIT ZCALL_RCRMBAPI with P_QUERy = Q2 and return .
    Endloop .
    Question: How do I make these calls in parallel u2013 yet retain control in the main program?
    A)       SUBMIT ZCALL_RCRMBAPI with P_QUERy = Q1 and return .
    B)      SUBMIT ZCALL_RCRMBAPI with P_QUERy = Q2 and return .

    Instead of RSCRM BAPI you can use the RRW3_QUERY_VIEW_DATA function module for greater control over program execution...
    /people/arun.varadarajan/blog/2009/07/29/make-the-most-out-of-query-execution--part-1
    will give you pointers as to how this can be done...

  • How to automate the queries

    hii everyone
    I want to automate queries.i.e they should be executed automatically on a particular day in the week. can we do it through oracle jobs..actually wht the case is i will be executing 5 queries evey tuesday.the output frm these queries are used to process another job tht runs every tuesday evening.rather than executing all these queries everytime i want to automate these queries.
    can anyone help me how to automate this job.
    thnakx

    hii justin
    thnkx for the reply..
    the queries wht im executing are little bit complex.one query is dependent on the other..im sending u the steps wht i will be doing when the queries are executed
    Below mentioned are the steps to be followed to check if the rewards job ran successfully or not –
    1.     Run the QUERY #1 in Rewards_Queries_Weekly_Test.sql
    2.     Note down the number of records returned in STEP 1.
    3.     Run the QUERY #2 in Rewards_Queries_Weekly_Test.sql.
    Enter current date as INPUT parameter.
    4.     Note down the number of records returned in STEP 3.
    5.     Compare the number of records returned in STEP 1 and
    number of records returned in STEP 3. BOTH THE NUMBERS
    SHOULD MATCH TO PROCEED TO NEXT STEP.
    6.     Copy the results of QUERY #1 to an excel sheet. Do not copy
    the serial number generated by PL/SQL Developer.
    Copy only the fields returned.
    7.     Copy the results of QUERY #2 to an excel sheet.
    Do not copy the serial number generated by PL/SQL Developer.
    Copy only the fields returned.
    8.     Assuming that the results of QUERY #1 were copied to the
    columns A1 & B1 and the results of QUERY #2 were copied to
    the columns D1 & E1, copy the following formula
    to F2 =IF((A2=D2)*(B2=E2),0,1)
    9.     The output of STEP 8 would be either 0 or 1 in the cell F2.
    1 indicates the records with mismatch and 0 indicates the correct
    records which can be ignored. It is possible that the records with
    mismatch have an entry in job special pay table and these records
    also can be ignored. These records can be filtered
    by following next steps.
    10.     Copy the data in the cells D1,E1 and F1 to H1, I1 and J1 respectively.
    While pasting use the option paste Special and select Values option
    in the dialog box.
    11.     Sort H1, I1 and J1 data by J1 descending and next by H1 ascending.
    This would list all the in correct records first and correct records next
    so that they can be ignored.
    12.     Now run the QUERY #3 and copy the results to K1. Do not copy the serial number generated by PL/SQL Developer. Copy only the fields returned. These records indicate the rewards special pay records given in the last one week.
    NOTE: The QUERY #3 expects two dates in the IN clause. These dates should be Current Date (Since the reward jobs run on Tuesday it will be always current Tuesday’s date) and Last Tuesday’s date.
    13.     Select all the incorrect records in the cells H1, I1 and J1 and apply
    the following conditional formatting formula with format as RED color.
    = VLOOKUP($H2,$K$2:$K$220,1,FALSE) <> " "
    NOTE: In the above formula change the value of K$220 based on the number of rows you get in the cell K from the results of QUERY #3.
    14.     The records with BLACK color are the actual records with some issue. Investigate each record manually and analyze the issue. Keep negative hours adjustment, 26 weeks rule in mind while doing so.
    the above are 14 steps i will be doing every tuesday when im executing the queries
    i want to automate the whole process wht im doing in the 14 steps..
    could u suggest me something on this
    srikanth

  • Want to count the number of rows of analysis item in WAD Template

    HI all,
    Detail Description:
    In my WAD report, i have a Export to Excel Option. But I want when I click on this button, one pop up will come only if no of rows of the Analysis Item is Greater than 10,000 ask for Do you want to proceed or not.
    Means 1st i want to count the no of rows in the Analysis Item, after that it will check, if the no of rows is greater that 10,000. then the pop up will come.
    Question:
    Does anyone know, "how to count the no of rows of the analysis Item ?" . It will be better if you know you to implement this with the help of java script.
    Means there must be some varible, which counts the no of rows. If you know then please help me

    Hi,
    Please find the below link which helps you to get solution of your question.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d0bbb20f-2d7e-2e10-258f-8655daa41fab?QuickLink=index&overridelayout=true
    It is mainly used to automate queries, web templates, and reports in different output formats like PDF, Excel,
    XML, XHTML, and HTML
    How to see WAD reports on browser:
    The BEx Web Application Designer is a desktop application for creating Web applications with BW-specific contents. Using the BEx Web Application Designer, you can create an HTML page that contains contents such as various tables, charts or maps. This HTML page (Web application) provides the basis for not only Web applications with complex interaction, but also for Web cockpits and iViews.
    http://help.sap.com/saphelp_nw04/helpdata/en/1a/456a3badc1b315e10000000a114084/content.htm
    Web Application Designer for Beginners
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/749a4622-0a01-0010-36bf-b6b30a2a3a22
    Web Application Solutions: A Designer's Guide
    http://www.lukew.com/resources/webapplicationsolutions.pdf
    http://sap.ittoolbox.com/groups/technical-functional/sap-solution-manager/bw-web-application-designer-1955944
    Feautures of WAD in 7.0
    http://help.sap.com/saphelp_nw70/helpdata/en/88/4d354277dcb26be10000000a155106/frameset.htm
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5c46376d-0601-0010-83bf-c4f5f140e3d6
    Regards
    Sudheer

  • Use of Variable - Refreshing the Queries in Workbook

    Hi All,
    I have a workbook which contains 5 Queries. All these queries uses the same variable. While I am refreshing all the  queries in the workbook, it pops-up the variable input screen 5 times.
    Here I just want the variable screen appear to be once and the same input be taken to all the queries.
    We are in 3.x.
    In 7.x Analyzer, I know that When you have multiple queries(with variables) embedded in a single workbook, we can use "Change Variables" icon to acheive the same.
    How can I achieve this in 3.5.
    Thanks in advance.
    Siva
    Edited by: Siva Reddy S on Jun 9, 2009 10:32 AM

    Hi Joke,
    Thanks for your reply.
    The option "save and reuse variable values" is something to do with the input values to save and reuse the same for the next time execution.
    Here I just wanted to input the variable at one query and the same value needs to be taken to all the queries. The Variable used in all the queries is the same one.
    Thanks again..
    Any body any inputs.
    Siva

  • How to get the queries behind a concurrent request

    Hi to all
    how to get the queries behind a concurrent request in oracle Apps R12
    Regards ,
    Zulqarnain

    IMHO you can not simple say that this query executed or another
    because many queries can be executed by one cp
    >
    My actually problem is that, i want to know that when Cost Summary Report from FA Responsibility is running then this concurrent program also run another CP. Populate Balanace Report . This CP also attach with
    Populate Balanace Report GT Data executable , This executable run FA_BALREP_PKG.populate_gt_table procedure.I want to know that which query is running for Cost Summary Report in above mention package.
    >
    it's look like that "Cost Summary Report from FA Responsibility" is main cp which generate the report based on some just-in-time data which generated by "Populate Balanace Report "
    in other words
    "FA_BALREP_PKG.populate_gt_table" populate data in some temp table for report and "Cost Summary Report" use it

  • Want to execute SQL Queries from Textfile

    I have a text file full of a bunch of sql queries, of the format:
    select something1, something2
    from someplace
    select something3, something4
    from someplace2
    select something5, something6
    from someplace3
    I want to execute these queries one at a time and then after each one executes, I will do something with the resultset. Question is, how do I pull each query from the text file one at a time and execute? I was doing this by using java.util.Scanner and java.lang.StringBuilder where I would scan one line at a time and then check to see if the line is empty, otherwise I append the line to the StringBuilder. If the line is empty, I process whatever is stored in the StringBuilder. The problem with doing this is that it does not preserve the newline from the text file, so I get queries that look like:
    "select something5, something6from someplace3"
    which of course are invalid. Does anyone know a better way to build SQL queries / statements from a text file? How do I get the newline or carriage return character?

    Just replace newline by space?

  • Subsidiary company, differentiate the client or company code?

    Hi All,
    I have a question. I am new to SAP and I want to implement SAP HR in subsidiary company. I will use the same server which has been use by parent company. The business process will be different between the two company and also the data will be separate completely.
    Do I need to differentiate the client? or better just differentiate the company code?
    What are the advantages and disadvantages between the two options?
    Thank you for your answer. It will be very helpful for me.
    Best Regards,
    Mart.

    Hi Mart,
    Because there usually is more than one way to do something in SAP, I will take the opposite view.  You should have only 1 production client, but separate the subsidiary by Company Code.  Thus, you will only have to do configuration once, rather than separate configuration in each client.  Also, master data is client specific, so you could not report on subsidiary employees if logged into the parent company client.  Employees could not be transferred between clients so you would have to terminate the employee in one client and hire them into the other.  Could easily do a transfer without having to recreate all master data by only a change in company code.  I know they promise there will be no transfers, but I guarantee after go-live, there will be many.  You did not mention Payroll or Benefits, but if either is managed by the Parent Company, then you would want all set-up and record generation done in one client, again arguing for all the master data to be available in that client.  You are also doubling the work for your Basis team by having to apply all updates, Support Packs, etc. in both clients.
    You may get arguments either way, it is up to you and the company which would be the better approach.
    Paul

  • I WANT TO FIND THE EXPIRY MATERIAL LIST DATE WISE

    I WANT TO FIND THE EXPIRY MATERIAL LIST DATE WISE

    Hi Prashant,
    Use TC - BMMC (Batch Cockpit)
    or Find all TC in one place
    SAP Easy Access
    Logistics
    |____ Central Functions
            |_________Batch Management  (Here you find all and suit your requirment)
    Note: Please assign valuable point in orde to encourage contributors for every answer to your queries.
    Best Regards,
    Silky

  • All user id's who made changes to the queries since created in production

    Hi all,
    I have  queries and structres in Production, and there are many users using the queries and strcutres and making changes to queries and structures. The end user are trained to become power users. So I want to know the all the user ids who  made the changes to queries or structures since created. If I go to properties I can know only the last changed user id and owner of the query or strucure.
    Any help is greatly appreciated
    Thanks,
    Raj.

    Raj,
    in general BW does not keep a change history. Typically the user ID of the creator and the one who changed an object the last time is stored.
    If you want "control", then have user create objects in development and transport them. The transport system will provide a complete change history (consistent through all objects, not just queries).
    Regards,
    Marc
    SAP NetWeaver RIG

  • How to find the queries based on the hierarchy

    Hi experts,
    Many queries are using one hierarchy.now I want to know which queries are using this hierarchy. How to make it? Thank you.
    Best regards,
    Gavin

    Under this object check where used list. Then you should get the list of queries where this hierarchy is used.
    Regards
    Rohini

Maybe you are looking for

  • Setup WSUS - Now My External Website Cannot be Accessed via Domain Machines

    Hi all, I recently set up a WSUS server for my company so I can manage updates to domain computers. I got it working and each domain computer now looks to the server (192.168.0.101) for updates. In addition, I have a DC on this machine as well which

  • Error while doing Delta using 0FI_AA_11 ..

    Hi Experts, I am trying to load ODS : 0FIA_DS11 (Transactions (Delta) using standard datasource : 0FI_AA_11 (FIAA: Movements). When I am trying to load I am getting following error : " <b>Extraction of 0FI_AA_11 not possible. Extract 0ASSET_AFAB_ATTR

  • Execute query. Not all records retrieved.

    Hi everyone. I have made a screen with the data block and layout wizzards. When I click on the default toolbar "Execute query" it brings only 68 records and there are about 25,000!. I have a botton which displays a LOV of the same table and the LOV i

  • BUG: Editing post after preview

    Reported by: Sidney San Martín, in this post When one previews a post and selects to continue editing it, his/her computer information appears in the message as HTML. If it is not removed, the final, posted message will have multiple copies of the in

  • PDF Automatically saves right after signing with an e-signature pad

    Hello, Our office is testing out an e-signature pad from Topaz. I've got it working just fine, the only problem is right affter someone signs with the e-signature pad the oringinal PDF saves itself. I would rather have the user use the save as option