SQL Query to search for most and least popular brands bought by spesific client and total

Hi to SQL query masters!
I need to create a report on most and least popular brand names within one specific client orders.
For example, during last month or a year among 100% of specific client's orders were 70% IBM products, 20% of HP and 10% Lenovo products.
How do I do that?
And I also think that it might be useful to have a query that shows top popular brands among all sales in given period of time – this statistic might improve warehouse turnover and marketing activities on least popular brand names.
I tried to use info from this link, but it didn’t help https://websmp106.sap-ag.de/~form/sapnet?_SCENARIO=01100035870000000183&_FRAME=OBJECT&_HIER_KEY=701100035871000439554&
Kind regards,
Ilya.

Hi
Please Check this
SELECT COUNT (T2.[CardCode]) as 'no of sales', T3.ItmsGrpNam,T2.Cardname
FROM rdr1 T0  INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode INNER JOIN ORDR T2 ON T0.DocEntry = T2.DocEntry
INNER JOIN OITB T3 ON T1.ItmsGrpCod = T3.ItmsGrpCod
WHERE T2.[DocDate] >= [%0] and  T2.[DocDate] <= [%1]
GROUP BY T3.ItmsGrpNam,T2.Cardname
ORDER BY COUNT (T2.[cardcode]) desc

Similar Messages

  • HT4623 I have just updated my i phone 4s with the new ios 6 software and most of my apps have disapeared when i got to the app store and search for an app i cant find i click on it and it says the app is installed. Iff i double click on it it opens. Any i

    I have just updated my i phone 4s with the new ios 6 software and most of my apps have disapeared when i got to the app store and search for an app i cant find i click on it and it says the app is installed. but i cant find it in my apps if i double click on it it opens. Any ideas?
    Thanks Pete

    I have the same problem.  Some of my purchased songs are missing also.

  • Can we implement the custom sql query in CR for joining the two tables

    Hi All,
    Is there anyway to implement the custom sql query in CR for joining the two tables?
    My requirement here is I need to write sql logics for joining the two tables...
    Thanks,
    Gana

    In the Database Expert, expand the Create New Connection folder and browse the subfolders to locate your data source.
    Log on to your data source if necessary.
    Under your data source, double-click the Add Command node.
    In the Add Command to Report dialog box, enter an appropriate query/command for the data source you have opened.
    For example:
    SELECT
        Customer.`Customer ID`,
        Customer.`Customer Name`,
        Customer.`Last Year's Sales`,
        Customer.`Region`,
        Customer.`Country`,
        Orders.`Order Amount`,
        Orders.`Customer ID`,
        Orders.`Order Date`
    FROM
        Customer Customer INNER JOIN Orders Orders ON
            Customer.`Customer ID` = Orders.`Customer ID`
    WHERE
        (Customer.`Country` = 'USA' OR
        Customer.`Country` = 'Canada') AND
        Customer.`Last Year's Sales` < 10000.
    ORDER BY
        Customer.`Country` ASC,
        Customer.`Region` ASC
    Note: The use of double or single quotes (and other SQL syntax) is determined by the database driver used by your report. You must, however, manually add the quotes and other elements of the syntax as you create the command.
    Optionally, you can create a parameter for your command by clicking Create and entering information in the Command Parameter dialog box.
    For more information about creating parameters, see To create a parameter for a command object.
    Click OK.
    You are returned to the Report Designer. In the Field Explorer, under Database Fields, a Command table appears listing the database fields you specified.
    Note:
    To construct the virtual table from your Command, the command must be executed once. If the command has parameters, you will be prompted to enter values for each one.
    By default, your command is called Command. You can change its alias by selecting it and pressing F2.

  • Query to search for independent DO

    Hi experts,
    I need a query to search for independent DO (DO without SO). I have been trying for quite sometime but the results appear to be duplicative and irrelevant. This is the syntax that I am using now,
    SELECT DISTINCT T0.[DocNum] as 'SO#', T0.[DocStatus], T0.[DocDate], T0.[CardName], T1.[ItemCode], T1.[Quantity], T3.[DocNum] as 'DO#'
    FROM ORDR T0  INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry
    RIGHT JOIN DLN1 T2 ON T2.TrgetEntry = T1.DocEntry
    INNER JOIN ODLN T3 ON T2.DocEntry = T3.DocEntry
    I think there are something wrong with the syntax but I just can't figure out where is wrong. Please help.
    Thank you.
    Best Regards,
    Alex

    Hi Alex,
    Try this,
    SELECT DISTINCT T0.DocNum as 'SO#', T0.DocStatus, T0.DocDate, T0.CardName,
    T1.ItemCode, T1.Quantity, T3.DocNum as 'DO#'
    FROM ORDR T0 INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry
    RIGHT JOIN DLN1 T2 ON T2.TrgetEntry = T1.DocEntry
    INNER JOIN ODLN T3 ON T2.DocEntry = T3.DocEntry
    WHERE T2.[BaseRef] = ' '
    OR
    SELECT T0.[DocNum], T0.[DocStatus], T0.[DocDate], T0.[CardCode], T0.[CardName],
    T1.[ItemCode], T1.[Dscription], T1.[Quantity]
    FROM ODLN T0 INNER JOIN DLN1 T1 ON T0.DocEntry = T1.DocEntry
    WHERE T1.[BaseRef] = ' '
    Regards,
    Madhan.

  • I dropped my macbook and it broke - I bought a new iMac and created a new itunes apple ID, and I forgot what the ID and Password of my broken macbook was - how do i retrieve the lost purchases and music from my forgotten ID?

    I dropped my macbook and it broke - I bought a new iMac and created a new itunes apple ID, and I forgot what the ID and Password of my broken macbook was - how do i retrieve the lost purchases and music from my forgotten ID?
    Regards,

    Well, it's kind of like walking into a bank and saying you forgot your name and address but you want access to your account, still:
    iTunes Customer Service Contact - http://www.apple.com/support/itunes/contact.html > Get iTunes support via Express Lane > iTunes > iTunes Store

  • SQL Query to search all the tables for a given string

    Hi all,
    This is concerning a query to search each and every table/column for a given string.
    I came across a similar post (Re: question about searching 600 tables and this query seems to be inline with my requirements:
    select table_name,
    column_name,
    :search_string search_string,
    result
    from cols,
    xmltable(('ora:view("'||table_name||'")/ROW/'||column_name||'[ora:contains(text(),"%'|| :search_string || '%") > 0]')
    columns result varchar2(10) path '.'
    where table_name in ('MY_TABLE')
    However, I am getting the following error:
    ORA-24451: OCIKCallPushTrusted, Maximum call depth exceeded
    I am using Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit and could you please let me know the best possible way to accomplish this task?
    Thanks.
    Edited by: itech.quest on Sep 19, 2010 8:30 AM

    Hi Tamir,
    Thanks so far. I am yet to make the crucial breakthrough as far my application goes. Are you talking about the EUL5_QPP_STATS table? I tried retrieving worksheets even from that table also with the following query
    SELECT DISTINCT Eul5QppStats.QS_DOC_NAME,Eul5QppStats.QS_DOC_DETAILS
    FROM EUL5_QPP_STATS Eul5QppStats,EUL5_DOCUMENTS Eul5Documents
    WHERE Eul5QppStats.QS_DOC_NAME = Eul5Documents.DOC_NAME
    However, the worksheet data retrieved by Discoverer Oracle's product is not matching my dataset for every workbook. Please suggest.
    Reg
    Thomas

  • SQL Query Too Large For Report Region

    Oracle Friends:
    I have a SQL query that is 24,000 characters long. APEX fails when I try to create a report using this query, probably because it is too long.
    I get an "ORA-01461: can bind a LONG value only for insert into a LONG column" after I paste it and try to go to the next page.
    Any ideas? I can't make my query any smaller without creating intermediate tables.
    Any help would be most appreciated.
    Regards,
    Rich Locus

    Hi,
    If possible, try to reduce the no. of characters from your SQL query. Ex. use shorter aliases etc in your query. Also, as suggested above, create some views which can form a part of your query and then use those views in your main query to reduce the total no. of characters.
    The report region source can take some limited no. of characters only. Exact figure is not known to me.
    Try the above suggestion and see if this works or not.
    Regards,
    Mangal

  • What SQL query I need for this?

    I need to execute a SQL query but I don't know how.
    To illustrate it, please take a look at some example data:
        ARTICLEID SOLDON    
        1         2005-12-31
        1         2005-11-31
        1         2005-10-31
        1         2005-09-31
        1         2005-08-31
        1         2005-07-31
        1         2005-06-31
        1         2005-05-31
        1         2005-04-31
        1         2005-03-31
        1         2005-02-31
        1         2005-01-31
        1         2004-12-31
        1         2004-11-31
        2         2005-12-31
        2         2005-11-31
        2         2005-10-31
        2         2005-09-31 This is a piece of the sales data for the articles (sales history).
    Lets assume that today is the date 2005-12-31.
    Two requirements for the query:
    1. Get the sales data for the last 12 months.
    2. Get only the sales data for articles where there is sales data since at least 6 months.
    The result in my example should look like this:
        ARTICLEID SOLDON    
        1         2005-12-31
        1         2005-11-31
        1         2005-10-31
        1         2005-09-31
        1         2005-08-31
        1         2005-07-31
        1         2005-06-31
        1         2005-05-31
        1         2005-04-31
        1         2005-03-31
        1         2005-02-31
        1         2005-01-31 What is the SQL which I need to accomplish this query?

    To get all the information from the last 12 months
    you will have to use date manipulation.
    SELECT add_months(sysdate, -12) from
    dual;This gives you the date 12 months ago.
    So you will have to select your date between then and
    the current date.If I do this I will get this data:
        ARTICLEID SOLDON    
        1         2005-12-31
        1         2005-11-31
        1         2005-10-31
        1         2005-09-31
        1         2005-08-31
        1         2005-07-31
        1         2005-06-31
        1         2005-05-31
        1         2005-04-31
        1         2005-03-31
        1         2005-02-31
        1         2005-01-31
        2         2005-12-31
        2         2005-11-31
        2         2005-10-31
        2         2005-09-31 But I want this data:
        ARTICLEID SOLDON    
        1         2005-12-31
        1         2005-11-31
        1         2005-10-31
        1         2005-09-31
        1         2005-08-31
        1         2005-07-31
        1         2005-06-31
        1         2005-05-31
        1         2005-04-31
        1         2005-03-31
        1         2005-02-31
        1         2005-01-31 I am no native English speaker. What didn't you understand in the two requirements?
    Here are my two requirements for the query:
    1. Get the sales data for the last 12 months.
    2. But get ONLY the sales data for articles where there is sales data since AT LEAST 6 months.
    The result can contain as many IDs as you want if the two requirements are met. Its not a trivial SQL statement for me. Please remember that the above data are only for illustration. They are just an example.
    There should be a SQL statement for this.
    Please tell me if you don't understand my problem. I will try to explain it in a better way if I can.

  • UCxn - Query to search for a specific email address

    I've got an odd issue...I've got a user in our London office on a completely separate voicemail system (Unity 5) that is receiving SMTP notifications from the voicemail system (UCxn 9.1.2) here in the US.  I'm wondering if there's a query I can run against the database to search for her email address and see if it is in the US cluster someplace?  I'm not a DB guy at all, so when it comes to SQL, I'm lost.
    Appreciate any help someone can provide
    SJ           

    You can try the user data dump from the ciscounitytools online and then just search the output and see if it's in there.
    HTH
    java
    if this helps, please rate
    www.cisco.com/go/pdihelpdesk

  • Crystal's "Show SQL Query" like feature for OracleReports

    Dear experts, after finding the solution for RDf to CrystalRPT conversion, i need to ask 3 possiblities rather asking the same solution millionth time :)..
    1. Does oracle have some tool, internal lab built etc as seperate downloadable to serve as Crystal's "Show SQL Query".
    2. Can OracleDesigner, OracleDiscoverer help in this regard, i found no Import RDF feature there
    3. Can Oracle Optmizer be intercepted to show what resultant SQL(s) it ran for that report.
    4. Is there any way to intercept, diagnnose the SQL runing at Database so we grab the SQLs from there.
    I have opened an RDF in Notepad and though SQLs etc are visible unencrypted still it seems work of months or years for me.
    very thank full.

    Can v$session, v$sql http://www.oracle-training.cc/oracle_tips_v$sql.htm help for this... how to see which SQLs are sent by a particular report by a particular machine.

  • SQL Query Assistance Required for Full Outer Join

    Hi,
    Lets say I have two tables, i.e:
    TAB_A (colA1, colA2, colA3, colA4)
    TAB_B (colB1, colB2, colB3, colB4) where colB2 is a FK to colA1
    I am after an SQL query that will cater for both the following two scenarios.
    Scenario 1:
    TAB_A has two rows of data, i.e
    (1, ABC100, 1, WG_A)
    (2, ABC100, 2, WG_B)
    TAB_B has one row of data, i.e
    (1, 1, EMP_222, 4)
    I use the following SQL:
    select a.*, b.*
    from tab_a a FULL OUTER JOIN tab_b b ON (a.colA1 = b.colB2)
    where a.colA2 = 'ABC100'
    This returns two rows:
    1, ABC100, 1, WG_A, 1, 1, EMP_222, 4
    2, ABC100, 2, WG_B
    Now, what I actually would like my query to do is actually only return the row where a tab_b record exists, i.e, should only return one record:
    1, ABC100, 1, WG_A, 1, 1, EMP_222, 4
    This I can achieve by using a RIGHT OUTER JOIN instead above, but this causes issue with my scenario 2, which is the following set-up
    Scenario 2:
    TAB_A has only one row of data this time, i.e
    (2, ABC100, 2, WG_B)
    TAB_B has no data at all this time
    This returns no rows but I actually now want this single record from tab_a returned.
    I basically require an SQL query that will cater for both the top 2 scenarios, i.e, if a tab_b record exists from the outer join then only return this record along with tab_a data. If a tab_b record doesn't exist, then only return the tab_a record.
    Hope the above makes sense.
    Thanks.

    Is it what you need (not very elegant) ?
    SQL> select * from t_outer;
            ID CODE
             1 100
             2 100
    SQL> select * from t_inner;
    no rows selected
    SQL> with tab1 as (
      2  select a.id a_id, a.code, b.id b_id from t_outer a join t_inner b on
      3  (a.id = b.id and a.code = '100'))
      4  select * from tab1
      5  union all
      6  select a.*, null from t_outer a where not exists (
      7  select 1 from tab1)
      8  and a.code = '100'
      9  /
          A_ID CODE             B_ID
             1 100
             2 100
    SQL> insert into t_inner values(2);
    1 row created.
    SQL> with tab1 as (
      2  select a.id a_id, a.code, b.id b_id from t_outer a join t_inner b on
      3  (a.id = b.id and a.code = '100'))
      4  select * from tab1
      5  union all
      6  select a.*, null from t_outer a where not exists (
      7  select 1 from tab1)
      8  and a.code = '100'
      9  /
          A_ID CODE             B_ID
             2 100                 2
    Rgds.

  • Sql query when fired for first time

    Here is my query. I installed database and software using DBCA. Now i got connected to sql. Now my doubt is when I fired SELECT * FROM EMP from scott user, for the first time, what are the different steps followed to fectch the data. I mean how the user gets connected to the database and which background process works at what stages. Please give detailed explanation. Thanks.

    When connecting to the database the client makes a request to the listener, and the listener checks the availability of the requested database service and responds to the client with an ACCEPT message, which indicates connection dispatching.
    After that, the listener sends a RESEND message back to the client and uses this time to check the database service. The client recieves the RESEND message and sends the same request again to the Listener.
    After recieving the ACCEPT message the connection is established, and this connection is different depending if you are using a Dedicated Server or Shared Server configuration.
    When you issue the query:
    SELECT * FROM emp;Oracle checks in the Shared Pool, in the Data Dictionary cache if the object exists and if you have sufficient privileges to access it (user Scott in this case). It then checks the Library cache if this statement has been executed before. If it did, another parse will not be necessary. Then the SQL statement is parsed (if necessary), interpreted and executed.
    The DBRW (Database Writer) background process then checks in the Buffer Cache if the blocks which contain the information from the EMP table are already there. If they are, a physical read is not necessary and it fetches the rows from the Buffer Cache.
    If they are not, DBWR reads the data files, retrieves the data from them, store the related blocks in the Buffer Cache (so in the next executions of this query a physical read will not be needed) and then the data is shown to the user.
    There are other details envolved, but in a general view that is what happens.

  • Clues about query's - Search for date type at INBOX

    Hello Everyone,
    At IC Webclient, does anyone experiment to add a new search date type at INBOX, at "search for date" search parameter?
    I added a new date type at Date Management, ZDATA_PR.
    When I try to assemble the query parts, I use something like this:
    CL CL_CRM_QUERYAUI_RUN_BTIL
    METH READ_BUSINESS_TRANSACTIONS
    CALL METHOD cl_crm_report_qupart=>get_qupart_by_token
        EXPORTING
          iv_token     = 'DAT'
          iv_date_type = 'ZDATA_PAR'
          iv_from      = ls_query_aui-from
          iv_to        = ls_query_aui-to
        IMPORTING
          ev_qupart    = ls_qupart_range-querypart.
      APPEND ls_qupart_and   TO lt_query.
      APPEND ls_qupart_range TO lt_query.
    However, I'm rewarded with an error message telling me that I have problems with the query.
    Does anyone can give me clues how to perform this action? I'm clueless and there's not almost no information about this...
    Thanks and Kind Regards
    Bruno Garcia

    Just to solve a mistake at example code:
    CALL METHOD cl_crm_report_qupart=>get_qupart_by_token
    EXPORTING
    iv_token = 'DAT'
    iv_date_type = 'ZDATA_PR'
    iv_from = ls_query_aui-from
    iv_to = ls_query_aui-to
    IMPORTING
    ev_qupart = ls_qupart_range-querypart.
    APPEND ls_qupart_and TO lt_query.
    APPEND ls_qupart_range TO lt_query.
    does anyone has a suggestion or a clue to give?
    Thanks
    Bruno

  • Sql query w/search field, pagination issue

    I have a page with a query which uses a search field. I am able to scroll through to different pages of the results.
    How can I always make certain that the results returned start on pagination = 1. For example:
    I leave P10_SEARCH_FIELD = null and scroll to page 2 (item 11-20). I then do a search for 'VAN'. The results return, however rather than page 1 appearing, page 2 appears. Is there a way to reset pagination so that it will always show the first item?
    thanks

    never mind. in the branch I checked the reset pagination for this page and that did the trick.

  • HT5569 My i-touch keeps searching for a wi-fi network where it use to connect and all my other apple devices still connect. I have reset, reload, off and on and off and on....what else could I try?

    My ipod touch just keeps searching for a wi-fi connection in my house where it use to connect automatically. My other apple devices still are connecting so not the wi-fi. I have reset to original settings, turned off-on-off-on... nothing seems to work. Does anyone have any ideas?
    Thanks!

    Does the iPod connect to other networks?
    Does the iPod see the network?
    Any error messages?
    Do other devices now connect?
    Did the iPod connect before?
    Try the following to rule out a software problem:                 
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Power off and then back on the router
    - Reset network settings: Settings>General>Reset>Reset Network Settings
    - iOS: Troubleshooting Wi-Fi networks and connections
    - Wi-Fi: Unable to connect to an 802.11n Wi-Fi network
    - iOS: Recommended settings for Wi-Fi routers and access points
    - Restore from backup. See:
    iOS: How to back up
    - Restore to factory settings/new iOS device. (I think you did this)
    If still problem make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar

Maybe you are looking for

  • Recommendation: disk drive configuration

    I use my Mac Pro at work for some basic iMovie video editing, so I have very capacity requirements. I currently have multiple hard disks; my startup disk is a 500GB SATA in HDD bay 1. I have two 400GB SATA drives in HDD bays 2 & 3, RAIDed together wi

  • Receiver Mail Adapter for PI 7.1 ehp1

    Hi Experts, Is there a way by using Mail Adapter (Receiver) to read the contents of the payload (which is considered also as the attachment) to be included in the body of the email? Appreciate your help in advance. Thanks! Cheers, R-jay

  • J1iex entry problem.

    Dear All,                            User had done GRN & after that he is  doing J1IEX entry as he clicks on Post cenvat invoice he gets an Error " Balance in Transaction Currency" Now he is not able to proceed further. P.O Made for this is an Asset

  • Redo data not applied on logical standby database 10g

    after a network problem within the primary and the logical standby database. The redo data is not applied on the logical standby even if all the archived log are sent to it. The below is the output from v$archive_gap and DBA_LOGSTDBY_LOG SQL> select

  • Do all Flash FLV players resize the incoming video?

    I'm finding that the animations I make look best if rendered at full size and then played back in a player that is of a smaller size. I want to offer my content for syndication in websites that I don't have any control over. Is it standard practice f