Sales Oportunity / Activity Query Question

I am trying to create a query to look up all Activities assigned / associated with a specific Sales Oportunity. I can not determine how to join the the Activity / Activities to the Sales Oportunity.  I see the the table OCLG, Activities table , that there is a Business Partner column, but how do I determine if the Activity is associated with an Activity and if so, which Sales Oportunity?
Is there another table I need to join to?
Hope this makes sense.
Thanks in advance
Dana

hi,
Activity can be linked to a business partner,not to sales opportunity,
U can link sales opportunity indirectly with Acitivity via BP Code.
Develop this query
SELECT T0.OpprId, T0.CardCode, T1.ClgCode, T1.CardCode, T1.Notes
FROM OOPR T0 INNER JOIN OCLG T1 ON
T0.CardCode = T1.CardCode
Jeyakanthan

Similar Messages

  • Sales Order + Activity query

    Hi,
    I set up the following query in one company:
    SELECT T0.DocNum, T1.ClgCode, T3.U_NAME, T2.name, T1.endDate, T1.Priority, T0.CardCode, T0.CardName, T0.NumAtCard, T0.DocDate, T0.DocTotal
    FROM ORDR T0 LEFT OUTER JOIN OCLG T1 ON T0.DocNum = T1.DocNum LEFT OUTER JOIN OCLA T2 ON T1.status = T2.statusID LEFT OUTER JOIN OUSR T3 ON T1.AttendUser = T3.INTERNAL_K
    WHERE T0.DocStatus = 'O'
    When I replicate it in another company, I get the following error:
    SQL Server Native Client 10.0|| SQL Server||  Conversion failed when converting the nvarchar value 'STBs-EN-0002' to data type int. 'Received Alerts' (OAIB)
    The STBs value indicated is an Item Code/IMD record which isn't even referred to in the query so not sure why it's getting picked up and/or causing an error.
    When I separate the two parts of the query - one query on just open sales orders, another on activities - they both work. It seems to be with the linking of ORDR to the Activities tables (if I try just ORDR and OCLG I get the same error above).
    Any assistance on figuring out how to fix the query would be much appreciated,
    Heather

    Hi Heather,
    Try:
    SELECT T0.DocNum, T1.ClgCode, T3.U_NAME, T2.name, T1.endDate, T1.Priority,
    T0.CardCode, T0.CardName, T0.NumAtCard, T0.DocDate, T0.DocTotal
    FROM ORDR T0
    LEFT JOIN OCLG T1 ON T0.DocNum = T1.DocNum AND T1.DocType = '17'
    LEFT JOIN OCLA T2 ON T1.status = T2.statusID
    LEFT JOIN OUSR T3 ON T1.AttendUser = T3.INTERNAL_K
    WHERE T0.DocStatus = 'O'
    Thanks,
    Gordon

  • Error while activating query element.

    Dear All
                  Can any one tell this error .
                  When iam transporting the queries to BI production there is an errror in Transportation log that  error while activating query element.
    But  the querysis fine in Bi quality.
    Error : Error while activating "6899QYGVHJPGYUBLKA9SPHORZ".

    Hi
    Might be that query element was deleted(not used n was used before in dev) while creating cross check once in your query.
    First check what is that element which is not transported?
    use table RSZELTDIR to find out weather its a Var or CKF or RKF etc...
    then check for the same in the query in QA weather its active and ported fine to QA if not try to collect the element and transport to QA in a separate request.
    Regards
    KP

  • Hide Active Query

    Hi All,
    We have installed Buyer business package on portal . In Transaction processing view currently the POWL view shows all the active queries given below:-
    1. My Purchase Requisitions
    2. Purchase Requisitions to be created
    3. Purchase orders with confirmations
    4. Purchase Requisitions to be assigned
    5. Purchase orders on hold.
    I do not want to show "Purchase orders on hole" active query on portal. How can I remove this active query ?
    Regards,
    Namrata

    Hi,
    Thanks. Can you let me know where do I see this option to hide the query, I mean which transaction?

  • Sales order invoice query

    Hi
    Please send the sales order invoice query as basic columns.. Further I will modify the query according to the requirement.
    Pleas send to my personal ID: [email protected]
    Thanks
    Sree

    Thanks.  There's a few problems though.
    1)  It seems that OINV DocTotal != Balance Due.  I'm seeing a number of invoices where there was a balance due, but we applied additional money (either we took another incoming payment and applied it or applied money from the account balance, etc.) and yet it still shows a total.
    2)  It's pulling incoming payments from different customers.  I think this is because the table was joined based on "RCT2 T4 on T4.[DocEntry]  =  T3.[DocNum] and T4.[InvoiceId] = T2.[LineNum]"  In one example I have 2 incoming payments 446 and 614.  Both have the DocEntry 542, but one relates to A/R Invoice 542 (for a different client) while the other relates to Down Payment Invoice 542.  *I was able to fix this by adding WHERE T5.CardCode = [%0]*
    3)  I'm going to work with this a little bit and see if I can alter it to make it work for me.  Basically this query falls a little short on the following:
    -  Doesn't include incoming payments that aren't linked to a down payment invoice.
    -  Does not give the Invoice Total (I'd like to know how much of the SO was invoiced.  DocTotal seems to give me Amount Invoiced - Down Payments.  I'm not sure the best way to get this number.  Maybe I could do the sum of each line * tax + freight)
    -  Does not give the outstanding amount on an invoice.  The ARtotal [DocTotal] column gives me how much was owed when the invoice was created, but it doesn't tell me what is currently owed.
    -  Lastly it may complicate the query too much and could be left off, but it would be nice to see if they have any money from credits or incoming payments that has not been applied.  Perhaps this would be easily accomplished by simply pulling in their account balance.

  • How to create a graph like in Sales Oportunity - closing % field

    Hi,
    I need to create a graph like in Sales Oportunity -> closing % field.
    Any ideas how?
    Regards,
    Ana Silva

    If it is no problem to have the text with value of % outside the "graph", you may use rectangle (it_rectangle) with width x and height y and inside the rectangle put it_picture (height x) with file where is one color. Based on percent change the width of it_picture. You may easy simulate it in screen painter.

  • Windows Server 2008 R2 Activation Keys question - Bought a copy at a garage sale

    Hi, i recently (two days ago) bought a big box of old/newish computer stuff from a guy at a garage sale/business surplus sale. included were 40 copies of a tax program and then randomly tossed in the box was a copy of Windows Server 2008 R2 with a intact
    key. the sticker has not been removed from the case, but it is exposed. 
    i am nervous about installing it onto my server as i dont want to break everything i have setup if the keys are used. is there a way to see if these upgrade keys are used or not before i install? or how difficult would it be to rollback the changes if the
    keys are used in fact? i am nervous about doing this upgrade without knowing as it took me a bit of time to get my server set the way i wanted it and i am not too computer savvy. 
    i know that the copy of the server software is a legitimate due to all the nice sticker security. the ribbons are in perfect condition and such. 

    Hi Phyrosis,
    Agree with Dave, for licensing related issue, you’d better contact Microsoft licensing team. In the United States and Canada, you may call the licensing team directly at 1-800-426-9400
    (select option 4), Monday through Friday, 6:00 A.M. to 5:30 P.M. (PST) to speak directly to a Microsoft licensing specialist. In this way, you will know the detailed information about license.
    Worldwide customers can use the Guide to Worldwide Microsoft Licensing Sites http://www.microsoft.com/licensing/worldwide.aspx to find contact information
    in their locations.
    Thank you for your understanding!

  • Oracle 10g and parallel query question

    Hi Oracle on SAP Gurus!
    We are currently thinking of activating parallel query for certain segments (large application tables and indexes). We searched in SAPNet and SDN and have also studied the SAP Note 651060. But we did not find a complete answer to the following question which is very important for us:
    Which kinds of queries (despite from full table scan and index scan in partitioned indexes) support parallel queries and which ones do not support parallel queries?
    This is important for us to find out whether we have candidates for parallel queries or not.
    Thanx for any hint!
    Regards,
    Volker

    But why do you not propose to use parallel query in OLTP systems?
    If the queries are accessed very frequently you will just run out of cpu and io ressources. OLTP systems are (historical) typically multi user systems. You can off course use PQ for 'single user' activities, like index rebuilds, some batchjobs, but you shouldn't do for frequent user queries.
    If you have time look at this interesting Article [Suck It Dry - Tuning Parallel Execution|http://doug.burns.tripod.com/px.html]
    It is quite old, and you don't have to read all tech details, but i recommend having a look at the conclusions at the end.
    May it make sense to use partitioning of these tables in conjunction with parallel query?
    I know some guys, who do partitioning on OLTP systems, even SAP systems. But they don't use PQ then. The use partitioning to work on a smaller set of data. In your case the range scans, would need to scan only one partition, saving buffer cache and effectively speeding up execution. So you don't need PQ to scan all partitions at all, this would be a typical OLAP approach.
    Best regards
    Michael

  • SQL Query Question

    Hi,
    I am trying to filter my output from the query based on some conditions but not able to figure out how. May be I am just overlooking at the issue or is it something tricky.
    So, I have a query returning 4 rows of output out of which I need to filter the rows. I have created a table from the result of the query that I need to filter to make it simple. So below is my create table script and values that are obtained from my original query.
    CREATE TABLE TEMPACCT
      SOURCEKEY           NUMBER,
      FLAG                VARCHAR2(1),
      ITEMID              NUMBER(9)                 ,
      ITEMNAME            VARCHAR2(10)               ,
      ITEMKEY             NUMBER(9)                
    Insert into tempacct values (0, 'N', 100, 'ITEM1' , 9647);
    Insert into tempacct values (0, 'N', 200, 'ITEM2' , 9648);
    Insert into tempacct values (9648, 'N', 100, 'ITEM3' , 9813);
    Insert into tempacct values (9647, 'Y', 100, 'ITEM4' , 9812);
    SQL> select * from tempacct;
    SOURCEKEY F     ITEMID ITEMNAME      ITEMKEY
             0 N        100 ITEM1            9647
             0 N        200 ITEM2            9648
          9648 N        100 ITEM3            9813
          9647 Y        100 ITEM4            9812
    SQL> Tempacct table is the table created from the resultset of my original query.
    So from the above output, what I need is 3 rows. The logic to filter out the row is - If any of the row thathas sourcekey that is same as Itemkey in any of the 4 rows and flag is Y then remove the row which have flag =N and only display the one with Falg = Y.
    Ok, so, in this case the desired output would be
    SOURCEKEY F     ITEMID ITEMNAME      ITEMKEY
             0 N        200 ITEM2            9648
          9648 N        100 ITEM3            9813
          9647 Y        100 ITEM4            9812So here we compared between the first row and the fourth row, and since the sourcekey in fourth row is same as itemkey in first row and Flag is 'Y' for fourth row, we keep 4th row and remove the first row since the flag is 'N'. (and sourcekey is 0. the row that gets removed will always have sourcekey =0) .
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Release 10.2.0.4.0 - 64bit Production
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - ProductionAppreciate your help.

    Hi,
    ARIZ wrote:
    Although the original question is already been answered, I had another small modification to the same question and also seeking some clarification. I do not want to open a new thread just for a similar question.I think you'll get better replies faster if you do start a new thread.
    Not counting this one, there have been 13 replies to this thread. Not many people who havn't already been participating in this thread are going to start reading a thread with 13 replies. Those who do are going to waste a lot of time reading about issues that have already been resolved, and the are likely to understand the remaining issues incorrectly.
    I have been following the thread from the beginnning, and I'm starting to get confused about what the unresolved issues are.
    I believe there are two things you still need:
    (1) An explanation of the solution I posted yesterday, involving the analytic COUNT function.
    (2) A solution for a new problem involving the same tables
    If I got that wrong, start a new thread, asking just what you need to know. Copy any relevant parts (like the CREATE TABLE and INSERT statements) from this thread. You can include a link to this thread, but do your best to make sure people don't have to use it.
    I realize that's more work for you, but getting the best results, and getting them quickly, sometimes does require more work.
    <h2>(1) An explanation of the solution I posted yesterday, involving the analytic COUNT function.</h2>
    ARIZ wrote:
    Hi Frank,
    Just out of curiosity, I was trying to understand the Count analytical function that you have used in the solution.
                    COUNT ( CASE
                                 WHEN  ac.flag = 'Y'
                           THEN  1
                             END
                        ) OVER ( PARTITION BY  CASE
                                                   WHEN  sourcekey = 0
                                       THEN  acctkey
                                       ELSE  sourcekey
                                               END
                                  )     AS y_cntSo what I am thinking is, this would first partition the row with acctkey ( where sourcekey =0) and sourcekey and then within that partition, it will check whether ac.flag = Y or not, if it is 'Y' then it would return count as 1 else 0. Am I correct? In the mean time I am also reading the tutorials on Count() analytical query. I'm not sure I understand your explanation.
    This is not partitioning first by x, and then by y. There is only one expression in the PARTITION BY clause. Most often, a PARTITION BY clause refers to some column in the table, for example:
    SELECT  ename
    ,       job
    ,       sal
    ,       AVG (sal) OVER (PARTITION BY job)  AS avg_sal_for_job
    FROM    scott.emp;This divides the result set into mutually exclusive parts; there will be as many such parts as there are distinct values for the PARTITION BY column. In the simple query above, if there happen to be 5 different values for job, you will get 5 independent averages.
    In your problem, there is no one column that defines a partition. That is, these two rows belong to the same partition:
    . SOURCEKEY F   ACCTKEY
             0 N       9647
          9647 Y       9812even though none of the 3 columns are the same. We could create a view that had a single column, telling to which partition each row belonged, like this:
    . SOURCEKEY F   ACCTKEY PART_NUM
             0 N       9648     9648
             0 N       9647         9647
          9648 N       9813         9648
          9647 Y       9812         9647where part_num is the result of a CASE expression:
    CASE
        WHEN  sourcekey = 0
        THEN  acctkey
        ELSE  sourcekey
    ENDWe could then use that new column, part_num, in a (very simple) PARTITION BY clause. But there is no need to create a view, even an in-line view, for that: we can (and I did) use the CASE expression directly in a (not so simple) PARTITION BY clause.
    Why did I use COUNT? The important thing about each partition is whether or not it includes any rows with flag='Y'. I don;t know of any function that directly answers that question. There are lots of ways to get the correct answer, but I think the one that corresponds most closely to the question we really want to ask:
    "Do any rows have flag='Y'?" is
    "How many rows have flag='Y'?"
    The analytic function COUNT (x) returns a number (possibly 0) of rows in the partition where x is not NULL. So, as the argument to COUNT, I used
    CASE
        WHEN  ac.flag = 'Y'
        THEN  1
    --  ELSE  NULL          -- I did not explicitly say this, but it is the default
    ENDwhich returns either
    (a) the literal number 1 or
    (b) NULL
    Instead of the literanl number 1, I could have used any literal or expression, of any data type, that is not NULL). all that matters is we produce something non-NULL for COUNT to count.
    <h2>(2) A solution for a new problem involving the same tables</h2>
    Also, I was trying to modify this query to fit my other similar requirement where I would need following output
    Original output:
    SOURCEKEY F    ACCTKEY
    0 N       9648
    0   N      9647
    9648 N       9813
    9647 Y       9812
    So, the query should be smart enough to return only the last two rows where sourcekey >0 which is
    SOURCEKEY F    ACCTKEY
    9648 N       9813
    9647 Y       9812
    And In case there are only first two 2 rows in the table then , it should return only those two row and not check for sourcekey > 0 which would be .
    SOURCEKEY F    ACCTKEY
    0 N       9648
    0   N      9647 Is it something that I should be using analytical function to solve this requirement. I am trying to accomplish this new requirement.If I understand this problem correctly, it does indeed involve mutually exclusive divisions, but in this problem, the divisions correspond more closely to a single column in the table. We want to divide the table into two mutually exclusive groups:
    (A) rows where soucekey > 0, and
    (B) rows where sourcekey = 0
    We could do that with a CASE expression, but there happens to be a built-in function that works very nicely.
    SIGN (sourcekey) returns
    (A) 1 if sourcekey > 0, and
    (B) 0 if sourcekey = 0
    But what do we want to do with those divisions? We want to display rows only from the "best" of those divisions, where division (A) is coinsidered "better" than division (B). That is, if there are any rows in division (A), then we want to display only rows in division (A), but if there are no rows in division (A), then (and only then) we want to display rows in divison (B).
    This is an example of a Top-N Query , where we want to display N items from the top of an ordered list. A typical top-N query uses an analytic function (either ROW_NUMBER, RANK or DENSE_RANK, depending on how we want to handle ties) to assign numbers to each row (lower numbers for the "better" rows), and then uses "WHERE f <= n" to display only the n "best" ones. (A special case, though a very common one, is where N=1, that is, we're only interested in the row (or rows, if there happens to be a tie) with the "best" value. In this case, most people find it cleare to say "WHERE f = 1" ratehr than "WHERE f <= 1". Your problem is an exmple ot that special case.)
    SELECT  sourcekey
    ,     flag
    ,     acctkey
    FROM     (
             SELECT  ac.sourcekey
             ,         NVL (ac.flag, 'N')     AS flag
             ,         ac.acctkey
             ,         DENSE_RANK () OVER (ORDER BY  SIGN (sourcekey)     DESC)     AS division_num
                FROM    itemtable     i
             ,         finance     f
             ,         acct     ac
               WHERE   i.itemtableid1      = f.parentid1
               AND         i.itemtableid2      = f.parentid2
             AND         f.financekey      = ac.financekey
               AND         i.parenttableid      = 19063
    WHERE     division_num     = 1
    ;Notice I talked about "mutually exclusiive *divisions* " above, not "mutually exclusive *partitions* ".
    There is no PARTITION BY in the analytic clause above. PARTITION BY means we want a separate, independent caluclation for each partition. Here, we want one single numbering for the entire result set.
    We want all rows that tie for the "best" to be numbered 1, so we have to use DENSE_RANK (or RANK) rather than ROW_NUMBER.

  • Sales Orders Change Log question

    Hi All,
    I am currently working on a project that involves querying SAP Database to get custom reports via web browser, I've made a lot of advances and most of the site is ready but I'm missing just one item that I hope you could help me.
    Thing is I am working with the Sales Order change log and the problem comes one a user deletes a row. If I go to the change log inside SAP and see the differences a new record will be shown saying that row X was deleted and
    if I go to the database (ADOC and ADO1 tables) I don't have a way to see wich row was deleted.
    My way of doing this is to check for the number of rows on the current state of the sales order and check the same on the previous instance of the SO and see if a line was deleted. Then I would have to check row by row between instances what rows are there and what row is missing and store that info. I think this kind of approach will definitively kill the server.
    I was wondering if some one can give me a hint about how to approach this problem. Does any body know how SAP works on this area?
    I'm working with SAP2005A and SQL Server 2005 Standard Edition.
    Any help is greatly appreciated.
    Thanks!
    Alejandro.-

    Hola Alejandro,
    Thanks for your answer, as I see it I'm doing exactly what you proposed but the problem comes with the following scenarios:
    a.- If I post a new SO with two lines I will have on the ADO1 table two records with the values 0 and 1 for each line respectively but if I delete the item on LineNum = 1 and then I add a new item, this last item will be also created with LineNum value = 1. This is not a complicated thing to do but the problem comes when the user is used to work with SOs with several items at detail level and is used to add and erase lines once in a while and as I see it it's very difficult for me to track those specific changes. There's also the fact that on the Log table a new instance is created every time the user hits the update button regardless if a modification was actually made or not. I mean I would know that a line was deleted or added but I would have to start comparing each field on each line of a sales order with it's previous instance to check what was actually added/deleted and I'm afraid that this may affect the server performance. I know that SAP does this without affecting to much the system resources and that is what I'm trying to find.
    I forgot the other scenario I was considering he he I will post again as soon as I remember it but I hope I'm explaining this ok (I'm not very good at explaining...) If not let me know and I'll try to explain again.
    I'm also working on trying to get another approach to see what comes up...
    Thanks for checking this thread, your answers are helpful.
    Regards.

  • TCS4 + CS5.5 + *3* machines + Activation/Deactivation - Question Jumble

    I apologize in advance if this seems convoluted -- I have *tried* to make sure I'm saying only what needs to be said :-) Any help would be appreciated. [Note: I *did* try to 'chat' with a representative, but didn't even get through the deactivation question before they got stuck in scripted answer limbo.]
    On machine #1, I had previously installed TCS2.5 and CS5.5 (Design Standard). Thus I Acrobat X Pro (amongst many other apps, including Acrobat 9 Pro Extended) available.
    I recently installed TCS4 on machine #1 (which includes Acrobat XI Pro), but Acrobat X Pro and Acrobat 9 Pro are no longer available (error message: action is only valid for products that are currently installed).
    I also installed TCS4 on machine #2.
    I now need to use TCS4 on machine #3 (and machine #2). I can live without it on machine #1 for the time being, but would like to be able to use it again later.
    So...
    I need to deactivate TCS4 on machine #1 and activate it on machine #3. According to a page in the adobe help, I should be able to do this *without* removing the software from machine #1.
    Question: Is that correct?
    Question: Is there a time limit within which I have to reactivate, or am I good anytime?
    Question: Is there a limit to the number of times I can deactivate and reactivate the software, and/or a minimum period between deactivation and reactivation?
    When I deactivate TCS4 on machine #1, I will no longer have Acrobat available.
    Question: Can I *reinstall* Acrobat 9 Pro (from the TCS2.5 install) or Acrobat X Pro (from the CS5.5 install)?
    Question: Will installing this older version of Acrobat interfere with the Acrobat XI Pro that is already installed (which I will want to be able to use again later)?
    In a nutshell, I'm doing this because I need to keep confidential client information on machines #2 and #3 (cannot share the information on the same machine). They are the main clients for the TCS software. But, I will also need to use the TCS software, on occasion, for other clients using machine #1 (again, cannot share info on common machines). So... I need to be able to turn off the software on one machine and turn it back on on the other. (As you can infer, the issue of Acrobat versions (and other adobe software) applies to each machine -- I want to be able to keep two machines running current software, and have the third running my licensed extra copy of Acrobat.)
    Thanks all :-)

    Installation and activation are separate and distinct actions, completely independent.
    You can have installed Adobe software that is deactivated - it's still fully there but won't run.
    Don't tie yourself in knots - the easiest thing to do would be to contact Adobe customer service and have them reset the activation counts for all your product serial numbers to zero.  Then you can reactivate them exactly on the systems you want (just start the programs to do this).
    For more details, see:
    How to Move Adobe Software Between Computers, or from PC to Mac
    Hope this helps!

  • Simple Query Question - How do I return the Last 3 records of a Table?

    Question.
    For example, I have a table that has 50 records.
    How do I, specify in SQL to only return the last 3 records of the table.
    Select a.* from table a where ????

    I was just trying to show an example to a friend on
    how something like this would work and if it was even possible. But it won't work. Here's a simple example:
    SQL> create table emp
      2  (id)
      3  as
      4  select object_id
      5  from   all_objects
      6  order  by object_id;
    Table created.
    SQL> select *
      2  from  (select rownum rn
      3               ,b.*
      4         from   emp b)
      5  where  rn > ( select (max(rownum) - 3)
      6                from    emp)
      7  ;
            RN         ID
         40830      55891
         40831      55892
         40832      55893So far, so good. These are the "last 3" rows inserted. Now delete a bunch of rows and insert 3 new ones:
    SQL> delete emp where id < 40000;
    33423 rows deleted.
    SQL> commit;
    Commit complete.
    SQL> insert into emp values (60000);
    1 row created.
    SQL> insert into emp values (60001);
    1 row created.
    SQL> insert into emp values (60002);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select *
      2  from  (select rownum rn
      3               ,b.*
      4         from   emp b)
      5  where  rn > ( select (max(rownum) - 3)
      6                from    emp)
      7  ;
            RN         ID
          7410      55891
          7411      55892
          7412      55893Here's the problem. Even though the "last 3 rows" are 60000 - 60002, I still get the same ones as the first query.

  • ISE 1.2 Active Directory Question

    Hi,
    I have a question regarding using Active Directory as an External Identity Source.
    Our customer has 4 AD servers in their domain and thus 4 DNS entries for the domain. When I join ISE to the domain DNS resolves to one address and uses that machine to perform the join operation. What happens if the machine subsequently fails - does my ISE node need to leave and then re-join the domain or is this handled by some other method?
    Thanks
    Alan

    Assuming that they're part of the same AD domain ISE will learn all of the DCs in the domain and you'll likely find after a while that it has moved to a different DC. We have over 100 DCs in our domain and it works just fine, no intervention is required to get it to connect to a different DC if the one it's connected to disappears.
     

  • Sales By Amt Query Change

    Hello All -
    We have this Query used to view sales by Amt for each month.  Can we modify it so it does not show every month.  Instead, gives option to select the month at the start of the Query and only shows the month selected in the results?
    Keep everything else the same.
    Thanks!!
    Mike
    SELECT T0.ITEMCODE,
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 1 AND T1.ITEMCODE
    = T0.ITEMCODE) AS 'JAN Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 2 AND T1.ITEMCODE
    = T0.ITEMCODE) AS 'FEB Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 3 AND T1.ITEMCODE
    = T0.ITEMCODE) AS 'MAR Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 4 AND T1.ITEMCODE
    = T0.ITEMCODE) AS 'APR Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 5 AND T1.ITEMCODE
    = T0.ITEMCODE) AS 'MAY Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 6 AND T1.ITEMCODE
    = T0.ITEMCODE) AS 'JUN Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 7 AND T1.ITEMCODE
    = T0.ITEMCODE) AS 'JUL Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 8 AND T1.ITEMCODE
    = T0.ITEMCODE) AS 'AUG Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 9 AND T1.ITEMCODE
    = T0.ITEMCODE) AS 'SEP Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 10 AND T1.ITEMCODE
    = T0.ITEMCODE) AS 'OCT Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 11 AND T1.ITEMCODE
    = T0.ITEMCODE) AS 'NOV Amt',
    (SELECT SUM(T1.QUANTITY*T1.PRICE) FROM INV1 T1 with
    (NOLOCK) WHERE MONTH(T1.DOCDATE) = 12 AND T1.ITEMCODE
    = T0.ITEMCODE) AS 'DEC Amt'
    FROM dbo.OITM T0
    LEFT JOIN dbo.INV1 T1 ON T1.ItemCode = T0.ItemCode
    WHERE T0.SellItem = 'Y'
    GROUP BY T0.ItemCode,YEAR(T1.DOCDATE) HAVING YEAR(T1.DOCDATE) = YEAR(GETDATE())
    ORDER BY T0. ITEMCODE

    This would not be possible through a simple SQL.  You will need a combination of a VIEW or Stored Procedure.
    The Base query for getting the Start and Ending Month
    DECLARE @FROM VARCHAR(10), @TO VARCHAR(10)
    /* SELECT FROM  [dbo].[OFPR] T0 WHERE */ SET @FROM = /* T0.Code */ '[%0]'
    /* SELECT FROM  [dbo].[OFPR] T0 WHERE */ SET @TO = /* T0.Code */ '[%1]'
    SELECT (SELECT T0.F_RefDate FROM  [dbo].[OFPR] T0 WHERE T0.Code = @FROM) [FROM MONTH], (SELECT T0.T_RefDate FROM  [dbo].[OFPR] T0 WHERE T0.Code = @TO) [TO MONTH]

  • Sales By State Query

    Hello All -
    We would like to develop a query that shows us monthly sales by each US state and OUS locations.  For example, on the left most column, we would have each location.  Then subsequent columns to the right of that would have sales for each location in Jan, Feb, March, etc.
    Can anyone help with this?
    Thanks,
    Mike

    I tried first three months below:
    SELECT T0.State1 AS 'Bill-to State', (SELECT SUM(T1.DocTotal) FROM OINV T1 with (NOLOCK) INNER JOIN OCRD T2 ON T2.CardCode=T1.CardCode
    WHERE MONTH(T1.DOCDATE) = 1 AND T2.State1 = T0.State1
    AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'JAN Amt', (SELECT SUM(T1.DocTotal) FROM OINV T1 with (NOLOCK) INNER JOIN OCRD T2 ON T2.CardCode=T1.CardCode
    WHERE MONTH(T1.DOCDATE) = 2 AND T2.State1 = T0.State1
    AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'FEB Amt', (SELECT SUM(T1.DocTotal) FROM OINV T1 with (NOLOCK) INNER JOIN OCRD T2 ON T2.CardCode=T1.CardCode
    WHERE MONTH(T1.DOCDATE) = 3 AND T2.State1 = T0.State1
    AND YEAR(T1.DOCDATE) = YEAR(GETDATE())) AS 'MAR Amt',
    FROM dbo.OCRD T0 LEFT JOIN dbo.OINV T1 ON T1.CardCode = T0.CardCode
    GROUP BY T0.State1
    ORDER BY T0.State1
    But did not get any data -- not sure what I am doing wrong?!
    Mike

Maybe you are looking for

  • Tips for parsing xml in a shell script?

    Hello, I'm writing a shell script to extract info from an xml file to create various text files that share data in the form of custom entities declared at the top of the document (product id, name, version, copyright date, etc.). So far I'm using xml

  • Camera Card slot shows up as network sharepoint

    I work in a mac environment, five computers running osx 10.5 throught 10.8. they all show one camera card slot on the HP 6500 as a bloody sharepoint! Is there any way to make this card plug stop broadcasting on the network short of ripping out the et

  • How to force Display mode for screen

    I am pretty new to enhancements and this is probably an easy question: I have implemented an enhancement that does a security check for a specific business area. If the user is of a specific business area i want them to be able to edit the screen. (d

  • Can I "Lock" Photoshop CS3 and Bridge Together ?

    I like to have Photoshop and Bridge open together. However, every time I click on the Bridge interface, either accidentally or to reposition it etc. Photoshop vanishes and I have to bring it back. Whilst it is not a terrible malfunction it is irritat

  • Not enough virtual memory

    Sigh. We have an old Explore Parliament CD-ROM which was produced using MM Director 5 in 1999. The CD-ROM still sells (a bit) and runs on most Windows PCs. However, we see around 10% - 15% of our customers getting the Director error message: - - - "T