TOP query

What's wrong with this query?
SELECT TOP 8 WEEK_END_DATE FROM M_CAL ORDER BY WEEK_END_DATE DESC
Gettgin an error FROM keyword not found where expected...

Hi,
Can you tell us what is that TOP 8 ?
Is it a function?
Try this code,
SELECT *
  FROM (SELECT WEEK_END_DATE FROM M_CAL ORDER BY DESC)
WHERE ROWNUM < 9;With Best Regards,
Vijayasekaran.N

Similar Messages

  • SELECT TOP query in HANA

       Hi,
    Can somebody give me the HANA equivalent of the following SQL query:
    SELECT TOP (731-624+1) COLUMNNAME FROM TABLENAME
    In case of HANA, it gives syntax error near "(".

    Hi Yash,
    As per the HANA SQL syntax supported case is
    <select_clause> ::= SELECT [TOP <unsigned_integer>] [ ALL | DISTINCT ]
    <select_list>
    After Top only an unsigned intger is expected and cannot handle an <expression> like in your example.
    Hope this is useful.
    Best Regards,
    Ranjit

  • How TOP query will work in SQL Server?

    Hi Experts,
      While running TOP command, what internally happen in SQL Server Engine ? How its fetching TOP 10 rows from Table.
    Thanks
    Selva

    That is the *logical* query processing order, which isn't the same as the *physical* processing order.
    As for how SQL Server performs TOP, then as syggested it very much depends on whether there is an ORDER BY or not. Since, TOP is logically processed after ORDER BY, you change the semantics of the TOP operation a lot when you add ORDER BY. But as usual,
    we can't say anything about the physcial query order with having an example to talk about. Too many involved factors, like how the rest of the query look like, the schema, what indexes we have, data distribution etc.
    Tibor Karaszi, SQL Server MVP |
    web | blog

  • Filter TOP query so that a result cannot be in the top if the column value is already present in a previous row

    Hi,
    Any help would be appreciated. I have a query that is the top(5) but I want them to be distinct on only one column value, not on the entire row. Any help would be really appreciated.
    Regards,
       Seamus

    SELECT TOP 5 [DISTINCT COLUMN], MAX([SOME OTHER COLUMN]), MAX([SOME OTHER COLUMN], MAX([SOME OTHER COLUMN])
    FROM [TABLE]
    GROUP BY [DISTINCT COLUMN]
    This will do it, but the values may display incorrectly, since it's taking the MAX value of each partition of your distinct column, so another way would be:
    ;WITH CTE AS(
    SELECT *, ROW_NUMBER() OVER(PARTITION BY [DISTINCT COLUMN] ORDER BY NEWID()) AS RN
    FROM [TABLE])
    SELECT TOP 5 [DISTINCT COLUMN], [OTHER COLUMN], [OTHER COLUMN]
    FROM CTE
    WHERE RN = 1
    Thanks.

  • Query on top of query

    Hi All,
    If it possible in WEBI, Can we create query on the top of the query in WEBI. I checked in sub query but it is query in the query.
    select distinct DESK.fintransact from
    (select distinct Top.fintransact, (Top.credit - Top.debit) as Amount
       From
    Iowa.findetail Top
      inner join Iowa.fintransact Bug on Bug.fintransact = Top.fintransact
    where (Top.account='10690 30115075' or   Iowa.SAPAccountCode(Top.account) = '30115075')
                                                         AND (Bug.SUBLEDGER <> 'CD' AND Bug.SUBLEDGER <> 'CR' AND Bug.SUBLEDGER <> 'AP' AND Top.TRANSACTIONTYPE <> 'AP')
      and Bug.ACCTDATE  BETWEEN  to_date(@Prompt('Enter the  Account Beginning Date (MM/DD/YYYY) ','A',,mono,free),'MM/DD/YYYY') AND to_date(@Prompt('Enter the Account Ending Date (MM/DD/YYYY) ','A',,mono,free),'MM/DD/YYYY')
      and  Bug.COMPANY IN @Prompt('Iowa Health Name(s) or * for All','A','Sales Recap\Company',multi,free) OR ('*' IN @Prompt('Iowa Health Name(s) or * for All','A','Sales Recap\Company',multi,free))
    ) DESK
    group by DESK.fintransact having sum(DESK.amount) = 0 
    The issue is the Inside query contains 2 objects Top.fintransact, (Top.credit - Top.debit) as Amount with the following results for date range
    Inside Query
    Top.fintransact Amount
    204213 0
    204093 0
    204091 99595.01
    203431 32332.91
    322452 0
    342342 33516.88
    65765 0
    Top Query
    Top.fintransact Amount
    204213 0
    204093 0
    322452 0
    65765 0
    I tried different way like Result from another query. I should feed the Top query result to another query.

    Thanks a lot your query worked and I can see exact data.
    Could please help me in the following code this bit different which is in Custom SQL. In the code in the From Clause there is a code which acts as Table . How can I achieve this in WEBI as  a single .
    SELECT DISTINCT
      PENDETAIL.TRADE,
      PENDETAIL.PRODUCT,
      PENTRANSACT.ACCTDATE,
      PENDETAIL.PENTRANSACT,
      PENTRANSACT.SAP_DOCUMENT_NO,
      PENDETAIL.ACCOUNT,
      Iowa.SAPAccountCode(PENDETAIL.ACCOUNT) sapact,
      PENDETAIL.COUNTERPARTY,
      PENDETAIL.QUANTITY,     
      PENDETAIL.CREDIT,
      PENDETAIL.DEBIT,
      SHIPMENTPENDTL.VESSEL,
      PENDETAIL.DESCRIPTION,
      (( PENDETAIL.CREDIT ) - ( PENDETAIL.DEBIT )) amt,
      COUNTERPARTY_PENCP.SIC,
      Iowa.SAPProfitCenter(PENDETAIL.ACCOUNT) a,
      PENTRANSACT.COMPANY,
      PENDETAIL.SHIPMENT,
      PENDETAIL.SUBLEDGER,
      NVL(PENDETAIL.CONTRACT,DEV_GROSS_LENGTH_DETAIL.CONTRACT),
      PENDETAIL.PENDETAIL,
      PENDETAIL.QUANTITYSTATUS,
      PENDETAIL.QUALITY
    FROM
      PENDETAIL,
      PENTRANSACT,
      SHIPMENT  SHIPMENTPENDTL,
      COUNTERPARTY  COUNTERPARTY_PENCP,
      (Select distinct shipment, contract from PENdetail where contract is not null) DEV_GROSS_LENGTH_DETAIL
    WHERE
      ( PENTRANSACT.PENTRANSACT=PENDETAIL.PENTRANSACT  )
      AND  ( SHIPMENTPENDTL.SHIPMENT(+)=PENDETAIL.SHIPMENT  )
      AND  ( PENDETAIL.SHIPMENT = DEV_GROSS_LENGTH_DETAIL.SHIPMENT)
      AND  ( COUNTERPARTY_PENCP.COUNTERPARTY=PENTRANSACT.COMPANY  )
      AND  (
      PENTRANSACT.ACCTDATE  BETWEEN  @variable('Enter the Beginning Date (MM/DD/YYYY)') AND @variable('Enter the Ending Date (MM/DD/YYYY)')
      AND  Iowa.SAPAccountCode(PENDETAIL.ACCOUNT)  IN  ('30110075', '30115075', '40110075', '40115075')
      AND  PENTRANSACT.COMPANY  IN  @variable('Enter Company Name')
    In the code the difference is in the FROM Clause which acts a table :
      (Select distinct shipment, contract from PENdetail where contract is not null) DEV_GROSS_LENGTH_DETAIL
    In Where clause:
    AND  ( PENDETAIL.SHIPMENT = DEV_GROSS_LENGTH_DETAIL.SHIPMENT)
    Select  Clause:
      NVL(PENDETAIL.CONTRACT,DEV_GROSS_LENGTH_DETAIL.CONTRACT),
    For some code I think there is no need of derived table I guess.

  • Wwv_FLOW_FILE_OBJECTS$ query shows superior activity from Enterprise Manager

    Hello!
    A have noticed some bad performance on database, Enterprise manager says the next query is top query.
    SELECT  ID          ,
            MIME_TYPE   ,
            BLOB_CONTENT,
            FILENAME    ,
            FILE_CHARSET,
            FILE_TYPE   ,
            FLOW_ID     ,
            CREATED_ON  ,
            LAST_UPDATED
    FROM    WWV_FLOW_FILE_OBJECTS$
    WHERE   FILENAME              = :B2
            AND SECURITY_GROUP_ID = :B1
    I know its apex schema, but where is this code?
    also it says about virtual circuit wait.
    can you help me understand what is happening?

    Christian
    Thank you very much,
    I switched to Apex Listener over Weblogic Server that was already working, just added a new managed server and deployed apex.war and i.war on it.
    the server resources are very good now.

  • High Concurrent SQL query of DBSNMP user

    OS Linux
    DB 11.2.0.2
    we have a 12 node RAC box on exadata. We are doing the monitoring through the OEM GRID. In the 12th node we see a high concurrent sql query owned by the DBSNMP user.The concurrency is about 98% and it the top query in that instance. Please suggest me what we shoud do to decrease it.
    Below is the query
    SELECT s.inst_id, s.name, i.instance_name
    FROM gv$active_services s, gv$instance i
    WHERE s.name = :p1 AND s.inst_id = i.inst_id

    Hi,
    We applied the patch 9482559 which was suggested by oracle for a different issue and after applying this patch the high concurrent dbsnmp sql issue is gone.

  • Query join help

    Hello everyone, I kindly need help with a query I am trying to write. I think it's meant to be a kind of join but I'm a little unsure. Here is an example:
    select a.person_id, a.company, b.name, e.element, f.value
    from a, b, e, f
    where a.person_id = b.person_id
    and e.el_id = f.el_id
    -- e.t.c
    Lets say this returns
    person_id, company, name, element, value
    1, Vols, krog, lunch, 34
    2, Mols, flog, munch, 24
    The problem now is the table e. I want to get all values from table e that meet a certain criteria. As in:
    select e.element
    where e.name = 'EVALUE'
    Lets say this returns
    element
    food
    lunch
    munch
    And combine it with the top query. But I also want to show all of the other values, a.person_id, a.company, b.name for each row.
    So my goal is to have finally:
    person_id, company, name, element, value
    1, Vols, krog, lunch, 34
    1, Vols, krog, food, 0
    1, Vols, krog, munch, 0
    2, Mols, flog, munch, 24
    2, Mols, flog, food, 0
    2, Mols, flog, lunch, 0
    That is to have a default for zero where no join exists for value and not to duplicate anything although I could still use distinct.
    Can anyone help with this?

    with t1 as (
                select a.person_id, a.company, b.name, e.element, f.value
                  from a, b, e, f
                  where a.person_id = b.person_id
                  and e.el_id = f.el_id
                  -- e.t.c
         t2 as (
                select e.element
                 where e.name = 'EVALUE'
    select  person_id,
            company,
            name,
            t2.element,
            sum(
                case t1.element
                  when t2.element then value
                  else 0
                end
               ) value
      from  t1,
            t2
      group by person_id,
               company,
               name,
      order by person_id,
               company,
               name,
               t2.element
    /For example:
    with t1 as (
                select 1 person_id, 'Vols' company, 'krog' name, 'lunch' element, 34 value from dual union all
                select 2, 'Mols', 'flog', 'munch', 24 from dual
         t2 as (
                select 'food' element from dual union all
                select 'lunch' from dual union all
                select 'munch' from dual
    select  person_id,
            company,
            name,
            t2.element,
            sum(
                case t1.element
                  when t2.element then value
                  else 0
                end
               ) value
      from  t1,
            t2
      group by person_id,
               company,
               name,
               t2.element
      order by person_id,
               company,
               name,
               t2.element
    PERSON_ID COMP NAME ELEME      VALUE
             1 Vols krog food           0
             1 Vols krog lunch         34
             1 Vols krog munch          0
             2 Mols flog food           0
             2 Mols flog lunch          0
             2 Mols flog munch         24
    6 rows selected.
    SQL> SY.

  • Why is my query using the wrong index?

    Hi SQL Tuning experts....
    I'm running Oracle 11.2.0.2 EE on Solaris 10
    I've just checked my top SQL statements in OEM and drilling down on the top query of the list, I decided to run SQL Advisor on the query.
    Low and behold, it came back with a profile that gives me a 99.9% improvement.
    When I compared the original plan to the new plan the only difference is that the SQL Advisor is using a different index.
    Now, the dumb DBA question: why? why is Oracle picking the wrong index?
    original plan
    SELECT STATEMENT
      COUNT STOPKEY
        VIEW
          SORT ORDER BY STOPKEY          
            TABLE ACCESS BY INDEX ROWID     ARADMIN.T2179          TABLE
              INDEX RANGE SCAN          ARADMIN.T2179_C3     INDEXnew plan...
    SELECT STATEMENT
      COUNT STOPKEY
        VIEW
          SORT ORDER BY STOPKEY          
            TABLE ACCESS BY INDEX ROWID     ARADMIN.T2179               TABLE
              INDEX RANGE SCAN          ARADMIN.T2179_C536870923     INDEXThe stats:
    table has approx. 3.3Mil rows
    table segment is approx. 15G (5G of it is reclaimable space, but probably not related)
    table has fresh stats and indexes have been recently rebuilt
    indexes in this discussion are both b-tree
    the C3 column is number(15) with 2836897 distinct rows
    the C536870923 columns is VARCHAR2(255) with 1080533 distinct values
    Here is the actual query:
         SELECT *
    FROM (
    SELECT T2179.C1,C536871040,C536871037,C536870944,C3,C536870918,C536870919,
    C536870924,C536871048,C536871049,C536871050,C536870926,C536870925,
    C536870916,C4,C536871275,C536871095,C536870913
    FROM T2179
    WHERE ((T2179.C536870923 = :"SYS_B_0") AND (T2179.C3 > :"SYS_B_1")) ORDER BY C1 DESC )
    WHERE ROWNUM <= :"SYS_B_2"Obviously this is a good example of why we should use profiles. :-)
    Edited by: ji li on Feb 14, 2013 1:32 PM
    Sorry... I should have included the plan output
    I'm guessing this has something to do with the cardinality of the data in the columns.

    Dom.... I've already posted most everything. Here are the relevant init params and misc stuff you are asking for.
    NAME                                 TYPE                             VALUE
    object_cache_optimal_size            integer                          102400
    optimizer_capture_sql_plan_baselines boolean                          FALSE
    optimizer_dynamic_sampling           integer                          2
    optimizer_features_enable            string                           11.2.0.2
    optimizer_index_caching              integer                          0
    optimizer_index_cost_adj             integer                          100
    optimizer_mode                       string                           ALL_ROWS
    optimizer_secure_view_merging        boolean                          TRUE
    optimizer_use_invisible_indexes      boolean                          FALSE
    optimizer_use_pending_statistics     boolean                          FALSE
    optimizer_use_sql_plan_baselines     boolean                          TRUE
    plsql_optimize_level                 integer                          2
    db_file_multiblock_read_count        integer                          128
    db_block_size                        integer                          8192
    cursor_sharing                       string                           FORCE
    SNAME                          PNAME                                    PVAL1 PVAL2
    SYSSTATS_INFO                  STATUS                                         COMPLETED
    SYSSTATS_INFO                  DSTART                                         12-04-2012 12:28
    SYSSTATS_INFO                  DSTOP                                          12-04-2012 15:28
    SYSSTATS_INFO                  FLAGS                                        0
    SYSSTATS_MAIN                  CPUSPEEDNW                     2992.2746781116
    SYSSTATS_MAIN                  IOSEEKTIM                                   10
    SYSSTATS_MAIN                  IOTFRSPEED                                4096
    SYSSTATS_MAIN                  SREADTIM                             48027.271
    SYSSTATS_MAIN                  MREADTIM                             37217.102
    SYSSTATS_MAIN                  CPUSPEED                                  2978
    SYSSTATS_MAIN                  MBRC                                         0
    SYSSTATS_MAIN                  MAXTHR                               400782336
    SYSSTATS_MAIN                  SLAVETHR                               1403904
    13 rows selected.
    QL> l
      1  SELECT * FROM (
      2    SELECT
      3    T2179.C1,
      4    C536871040,
      5    C536871037,
      6    C536870944,
      7    C3,
      8    C536870918,
      9    C536870919,
    10    C536870924,
    11    C536871048,
    12    C536871049,
    13    C536871050,
    14    C536870926,
    15    C536870925,
    16    C536870916,
    17    C4,
    18    C536871275,
    19    C536871095,
    20    C536870913
    21    FROM aradmin.T2179
    22    WHERE (
    23     (C536870923 = '300885690')
    24    AND
    25     (C3 > '1360938353')
    26          )
    27    ORDER BY C1 DESC )
    28* WHERE ROWNUM <= 1
    no rows selected
    Elapsed: 00:00:00.01
    Execution Plan
    Plan hash value: 2768254526
    | Id  | Operation                      | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT               |          |     1 |  2315 |     6  (17)| 00:00:01 |
    |*  1 |  COUNT STOPKEY                 |          |       |       |            |          |
    |   2 |   VIEW                         |          |     1 |  2315 |     6  (17)| 00:00:01 |
    |*  3 |    SORT ORDER BY STOPKEY       |          |     1 |   226 |     6  (17)| 00:00:01 |
    |*  4 |     TABLE ACCESS BY INDEX ROWID| T2179    |     1 |   226 |     5   (0)| 00:00:01 |
    |*  5 |      INDEX RANGE SCAN          | T2179_C3 |     1 |       |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter(ROWNUM<=1)
       3 - filter(ROWNUM<=1)
       4 - filter("C536870923"='300885690')
       5 - access(SYS_OP_DESCEND("C3")<HEXTORAW('3AF1C2A1ABC9FF') )
           filter(SYS_OP_UNDESCEND(SYS_OP_DESCEND("C3"))>1360938353)
    Statistics
              0  recursive calls
              0  db block gets
           2615  consistent gets
              0  physical reads
              0  redo size
           1538  bytes sent via SQL*Net to client
            513  bytes received via SQL*Net from client
              1  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
              0  rows processed

  • Link between xla_distribution_links and ap_invoices_all

    SELECT SUP.VENDOR_NAME,
                  API.INVOICE_NUM,
                  SUM (NVL (AEL.ACCOUNTED_DR, 0) - NVL (AEL.ACCOUNTED_CR, 0)) "BALANCE"
    FROM xla.xla_ae_lines AEL,
             xla.xla_ae_headers AEH,
             (SELECT   XDL.AE_HEADER_ID,
                              XDL.AE_LINE_NUM,
                              XDL.APPLIED_TO_SOURCE_ID_NUM_1,
                              XDL.ALLOC_TO_SOURCE_ID_NUM_1,
                              APSI.INVOICE_NUM "ALLOC_TO_INVOICE_NUM",
                              XDL.EVENT_CLASS_CODE
                FROM APPS.XLA_DISTRIBUTION_LINKS XDL, AP.AP_INVOICES_ALL APSI
               WHERE XDL.APPLICATION_ID = 200
                     AND XDL.EVENT_CLASS_CODE IN
                            ('PREPAYMENTS', 'PREPAYMENT APPLICATIONS')
                     AND XDL.ROUNDING_CLASS_CODE = 'PREPAID_EXPENSE'
                     AND XDL.ALLOC_TO_SOURCE_ID_NUM_1 = APSI.INVOICE_ID
                     GROUP BY XDL.AE_HEADER_ID,
                              XDL.AE_LINE_NUM,
                              XDL.APPLIED_TO_SOURCE_ID_NUM_1,
                              XDL.ALLOC_TO_SOURCE_ID_NUM_1,
                              APSI.INVOICE_NUM,
                              XDL.EVENT_CLASS_CODE
                     ) dl, --------------VERY IMPORTANT---------------
             GL.GL_CODE_COMBINATIONS CC,
             AP.AP_SUPPLIERS SUP,
             AP.AP_INVOICES_ALL API
       WHERE     aeh.balance_type_code = 'A'
             AND aeh.ae_header_id = ael.ae_header_id
             ---hh
             AND aeh.ae_header_id = DL.ae_header_id
             AND ael.ae_line_num = DL.ae_line_num
             AND ael.ledger_id = 2022
             AND ael.code_combination_id = CC.CODE_COMBINATION_ID
             AND DL.APPLIED_TO_SOURCE_ID_NUM_1 = API.INVOICE_ID --------------VERY IMPORTANT-----------------
             AND CC.SEGMENT1 = '131061'
             AND AEL.PARTY_ID = SUP.VENDOR_ID
             AND SUP.VENDOR_NAME = 'COMPANY_NAME'
             AND TRUNC (AEH.ACCOUNTING_DATE) <= TO_DATE ('31-DEC-2012', 'DD-MON-YYYY')
    GROUP BY API.INVOICE_NUM,  SUP.VENDOR_NAME
    HAVING          SUM (NVL (AEL.ACCOUNTED_DR, 0) - NVL (AEL.ACCOUNTED_CR, 0)) <> 0
    Pleaes explain the above query. The result is the prepayment balance grouped by Vendor_name and Invoice_num. What I don't understand is the use of the inline view DL. Why would you need it? I tried to rewrite the above task as following.
    select  inv.vendor_id, INV.INVOICE_NUM, sum(AEL.ACCOUNTED_DR) - sum(AEL.ACCOUNTED_CR) balance
    from xla.xla_ae_lines ael,
            xla.xla_ae_headers  aeh,
            XLA.XLA_DISTRIBUTION_LINKS xld,
            AP.AP_INVOICES_ALL inv,
            ap.ap_invoice_distributions_all dist,
            AP.AP_SUPPLIERS sup
    where ael.ae_header_id = aeh.ae_header_id AND
                XLD.AE_HEADER_ID = aeh.ae_header_id AND
                inv.invoice_id = dist.invoice_id AND
                INV.vendor_id = SUP.VENDOR_ID AND
                INV.VENDOR_ID = 407012 AND
                AEL.APPLICATION_ID = 200 AND
                INV.INVOICE_NUM = '30'
    Group by inv.vendor_id, INV.INVOICE_NUM
    I linked AP_INVOICES_ALL to XLA_DISTRIBUTION_LINKS with APPLIED_TO_SOURCE_ID_NUM_1. But in the first query I posted, XLA_DISTRIBUTION_LINKS and AP_INVOICES_ALL were joined twice - first in the inline view DL using ALLOC_TO_SOURCE_ID_NUM_1, then in the main query using APPLIED_TO_SOURCE_ID_NUM_1. Oracle ETRM says nothing about the usage of ALLOC_TO_SOURCE_ID_NUM_1. So I am totally confused. Any hints would be appreciated    

    In the top query the detail level of information has been gathered from the sub query DL to make the query easy to understand but when one uses a sub query the performance takes a hit.
    Thanks&Regards
    [email protected]

  • Stuck on few CSS issues mid-build

    Hi all,
    Spend the last week making some good progress with a website build, but I’ve hit a few stumbling blocks I hoped the CSS pros out there might be able to help with please!
    <div id="body_container">
    I’ve tried setting this div’s height to 100% so it expands accordingly (set to 800px right now), but when I do this it ‘disappears’ from view – i.e. the background colour vanishes and all its contents appear on a white background which is applied to the #body_container_fullwidth. Any ideas what I’m doing wrong?
    <div id="left_content">
    Why isn’t this expanding in height to accommodate the youtube video? It’s height is set to 100%.
    <hr class="leftcontent1"></hr>
    I’m seeing this in Dreamweaver but not in FF or IE preview. Any ideas?
    <img class="rightbutton" src="Images/right_button.png" width="24" height="24" alt="More" />
    I’ve put this image in the <div id="right_content_greystrip"> container but it’s appearing below and I can’t work out why?
    Sorry it’s quite a few issues all at once – I’ve been over each time and time again but am thoroughly stuck!
    Thanks in advance guys
    <!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="PageTitle" -->
    <title></title>
    <!-- TemplateEndEditable -->
    <link href="CSS/style_sheet.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript">
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-17957242-1']);
      _gaq.push(['_trackPageview']);
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    </script>
    </head>
    <body>
    <div id="logo_address_container_fullwidth">
    <div id="logo_address_container">
    <div id="logo_container"><a href="Templates/test.com"><img src="Images/thewharfhouse-logo.png" width="359" height="41" alt="The Wharf House" /></a></div>
    <div id="address_container">
    <p class="headeraddress">Over, Gloucester, GL2 8DB | 01452 332 900 | <a href="Templates/www.test.com">[email protected]</a></p>
    </div>
    </div>
    </div>
    <div id="nav_container_fullwidth">
    <div id="nav_container">
    <p class="nav"><a href="Templates/www.test.com">Home</a>  &#8226;  <a href="Templates/www.test.com">Restaurant</a>  &#8226;  <a href="Templates/www.test.com">Accommodation</a>  &#8226;  <a href="Templates/www.test.com">Online Shop</a>  &#8226;  <a href="Templates/www.test.com">News & Events</a>  &#8226;  <a href="Templates/www.test.com">Functions & Weddings</a>  &#8226;  <a href="Templates/www.test.com">Local Tourism</a>  &#8226;  <a href="Templates/www.test.com">Contact</a></p>
    </div>
    </div>
    <div id="header_image_container_fullwidth">
    <div id="header_image_container">
      <!-- TemplateBeginEditable name="header-image" --><img src="Images/header-test.jpg" width="1100" height="350" alt="Header test" /><!-- TemplateEndEditable --></div>
    </div>
    <div id="body_container_fullwidth">
    <div id="body_container">
    <div id="body_container_left">
    <div id="left_content">
    <h1 class="leftcontent1">Welcome to The Wharf House</h1>
    <hr class="leftcontent1"></hr>
    <h2>Welcome to the award winning waterside Restaurant and Accommodation, situated in Over on the edge of the historic city of Gloucester.</h2>
    <p>Welcome to The Wharf House Waterside Restaurant with Rooms, set in the perfect riverside location. Sample our culipxary delights, which have recently been awarded a highly acclaimed red rosette by the AA or enjoy a stay in our beautiful rooms awarded with 4 stars by the AA.</p>
    <p>Each of our 6 bedrooms provide wonderful views of the River Severn, or our newly restored Canal Basin. All rooms are equipped with wide-screen TV’s, walk in WiFi, and private en suite facilities, some with whirl-pool baths.</p>
    <p>All rooms include breakfast the following morning. Breakfast is served between 7.30am-9.30am Monday to Friday and 8.30am-9.45am Saturday and Sunday
    (earlier if required at a supplement of £5 per room per half hour).</p>
    <p>All profits made by The Wharf House are used for the promotion and restoration of the Herefordshire and Gloucestershire Canal Trust.</p>
    </div>
    <div id="left_content">
    <h1 class="leftcontent2">The Wharf House video showcase</h1>
    <div id="youtube">
    <iframe width="380" height="214" src="http://www.youtube.com/embed/f8UT6QJIMfE" frameborder="0" allowfullscreen></iframe>
    </div>
    <p>Take a look inside The Wharf House restaurant and rooms in Over, near Gloucester, with naration from Natasha Turney at the restaurant.</p>
    </div>
    </div>
    <div id="body_container_right">
    <div id="right_content">
    <h1 class="rightcontent">Book your stay</h1>
    <img class="rightcontent" src="Images/right_content_test.png" width="120" height="90" alt="Test" />
    <p>Check availability and book your stay in one of our luxurous individual rooms.</p>
        <div id="right_content_greystrip">
              <p class="right_content_greystrip"><a href="Templates/test.com">Check room availability</a></p>
            <a href="Templates/test.com"><img class="rightbutton" src="Images/right_button.png" width="24" height="24" alt="More" /></a></div>
         </div>
    <div id="right_content">
    <h1 class="rightcontent">Over Canal Festival 2012</h1>
    <img class="rightcontent" src="Images/right_content_test.png" width="120" height="90" alt="Test" />
    <p>Don’t miss the Over Canal Festival on Saturday 1 and Sunday 2 September 2012, featuring Prunella Scales and Timothy West, heritage boat processions, fun on the water, great food and drink, music and lots more!</p>
    </div>
    <div id="right_content">
    <h1 class="rightcontent">Christmas 2012 menus available now</h1>
    <img class="rightcontent" src="Images/right_content_test.png" width="120" height="90" alt="Test" />
    <p>Turkey is banned for another year at The Wharf House, but instead you’ll find a tempting selection of courses sure to please even the pickiest eater in your party. Plus, a buffet menu is also available this festive season.</p>
    </div>
    </div>
    </div>
    </div>
    <div id="top-footer_container_fullwidth">
    <div id="top-footer_container">
    <p class="footertop">The Wharf House, Over, Gloucester, GL2 8DB | 01452 332 900 |<a href="Templates/www.test.com"> [email protected]</a></p>
    </div>
    </div>
    <div id="middle-footer_container_fullwidth">
    <div id="middle-footer_container">
    <div id="middle-footer_container_text">
    <p class="footermiddle">Awards and accolades</p>
    </div>
    <div id="middle-footer_container_awardsaccolades_img"><img src="Images/aa-accommodation-logo.png" alt="AA 4 Star Guest Accommodation" width="63" height="100" class="awardsaccolades" /></div>
    <div id="middle-footer_container_awardsaccolades_img"><img src="Images/aa-restaurant-logo.png" alt="AA Rosette Restaurant" width="64" height="100" class="awardsaccolades" /></div>
    <div id="middle-footer_container_awardsaccolades_img"><img src="Images/green-tourism-silver-logo.png" alt="Silver Green Tourism" width="77" height="100" class="awardsaccolades" /></div>
    <div id="middle-footer_container_text">
      <p class="footermiddle">Social media links</p>
    </div>
    <div id="middle-footer_container_socialmedia_img"><a href="https://www.facebook.com/TheWharfHouse" target="_blank"><img src="Images/facebook-logo.png" alt="Facebook" width="109" height="41" class="socialmedia" /></a></div>
    <div id="middle-footer_container_socialmedia_img"><a href="https://twitter.com/thewharfhouse" target="_blank"><img src="Images/twitter-logo.png" alt="Twitter" width="121" height="41" class="socialmedia" /></a></div>
    </div>
    </div>
    <div id="bottom-footer_container_fullwidth">
    <div id="bottom-footer_container">
    <p class="footerbottom1"><a href="Templates/www.test.com">Home</a>  &#8226;  <a href="Templates/www.test.com">Restaurant</a>  &#8226;  <a href="Templates/www.test.com">Accommodation</a>  &#8226;   <a href="Templates/www.test.com">Online Shop</a>  &#8226;  <a href="Templates/www.test.com">News & Events</a>  &#8226;  <a href="Templates/www.test.com">Functions & Weddings</a>  &#8226;  <a href="Templates/www.test.com">Local Tourism</a>  &#8226;  <a href="Templates/www.test.com">Contact</a></p>
    <p class="footerbottom2">All profits from The Wharf House will be used for the promotion and restoration of the Hereford and Gloucester Canal. &copy; 2012.</p>
    </div>
    </div>
    </body>
    </html>
    @charset "utf-8";
    html {
        min-height: 100%;
        margin-bottom: 1px;
    body {
        background-color: #FFFFFF;
        margin-left: 0px;
        margin-right: 0px;
        margin-top: 0px;
        margin-right: 0px;
    p {
        font:Arial, Helvetica, sans-serif;
        color: #666666;
        font-size: 14px;
        margin-bottom: 1.2em;
        margin-top: 0em;
        line-height: 1.4em;
        text-align: left;
        font-weight: normal;
        margin-left: 15px;
        margin-right: 15px;
    p.headeraddress {
        margin-bottom: 1.2em;
        margin-top: 0em;
        font:Georgia, "Times New Roman", Times, serif;
        font-size: 15px;
        text-align:left;
        color: #666666;
    p.nav {
        margin-bottom: 1.2em;
        margin-top: 0em;
        font:Georgia, "Times New Roman", Times, serif;
        font-size: 16px;
        color: #FFF;
        text-align:center;
    p.nav a:link {
        color: #FFF;
        text-decoration: none;
    p.nav a:visited {
        text-decoration: none;
        color: #FFF;
    p.nav a:hover {
        color: #FFF;
        text-decoration: underline;
    p.nav a:active {
        color: #FFF;
        text-decoration: underline;
    p.footertop {
        margin-bottom: 1.2em;
        margin-top: 0em;
        font:Georgia, "Times New Roman", Times, serif;
        font-size: 15px;
        text-align:center;
        color: #666666;
    p.footermiddle {
        margin-bottom: 1.2em;
        margin-top: 0em;
        font:Georgia, "Times New Roman", Times, serif;
        font-size: 12px;
        font-style: italic;
        text-align:right;
        color: #666666;
    img.awardsaccolades {
        display: block;
        margin-left: auto;
        margin-right: auto;
    img.socialmedia {
        display: block;
        margin-left: auto;
        margin-right: auto;
    p.footerbottom1 {
        margin-bottom: 1.2em;
        margin-top: 0em;
        font:Georgia, "Times New Roman", Times, serif;
        font-size: 15px;
        text-align:center;
        color: #666666;
    p.footerbottom2 {
        margin-bottom: 1.2em;
        margin-top: 0em;
        font:Georgia, "Times New Roman", Times, serif;
        font-size: 12px;
        font-style: italic;
        text-align:center;
        color: #666666;
    img {
        border: 0px;
    h1.leftcontent1 {
        font:Georgia, "Times New Roman", Times, serif;
        font-size: 24px;
        color: #840000;
        margin-left: 15px;
        margin-right: 15px;
        margin-bottom: 0px;
        font-weight:400;
    h1.leftcontent2 {
        font:Georgia, "Times New Roman", Times, serif;
        font-size: 20px;
        color: #666666;
        margin-left: 15px;
        margin-right: 15px;
        margin-bottom: 10px;
        font-weight:400;
    h1.rightcontent {
        font:Georgia, "Times New Roman", Times, serif;
        font-size: 20px;
        color: #666666;
        margin-left: 15px;
        margin-right: 15px;
        margin-bottom: 10px;
        font-weight:400;
    img.rightcontent {
        float:left;
        margin-left: 15px;
        margin-right: 12px;
    #youtube {
        float:left;
        margin-left: 15px;
        margin-right: 12px;
    hr.leftcontent1 {
      border: 1px;
      width: 520px;
      color: #840000;
      height: 1px;
      margin-left: 15px;
      margin-top: 6px;
    h2 {
        font:Georgia, "Times New Roman", Times, serif;
        font-size: 16px;
        font-style:italic;
        color: #666666;
        margin-top: 0px;
        margin-left: 15px;
        margin-right: 15px;
        margin-bottom: 15px;
        font-weight:400;
    a:link {
        color: #840000;
        text-decoration: none;
    a:visited {
        text-decoration: none;
        color: #840000;
    a:hover {
        color: #840000;
        text-decoration: underline;
    a:active {
        color: #666666;
        text-decoration: underline;
    #logo_address_container_fullwidth {
        width: 100%;
        height: 100%;
        float:left;
        background-color:#F1EACE;
        margin: auto;
        padding-top: 35px;
    #logo_address_container {
        width: 960px;
        height: 74px;
        background-color:#F1EACE;
        margin-left: auto;
        margin-right: auto;
        padding: 0px;
    #logo_container {
        width: 359px;
        height: 41px;
        float:left;
        padding-left: 20px;
    #address_container {
        width: 561px;
        height: 20px;
        float:left;
        padding-left: 20px;
        margin-top: 14px;
    #nav_container_fullwidth {
        width: 100%;
        float:left;
        background-color:#840000;
        margin: auto;
        padding: 0px;
    #nav_container {
        width: 960px;
        height: 30px;
        background-color:#840000;
        margin-left: auto;
        margin-right: auto;
        padding-top: 6px;
    #header_image_container_fullwidth {
        width: 100%;
        height: 350px;
        float:left;
        background-color:#F1EACE;
        margin: auto;
        padding: 0px;
    #header_image_container {
        width: 1100px;
        height: 100%;
        background-color:#F1EACE;
        margin-left: auto;
        margin-right: auto;
        padding: 0px;
    #body_container_fullwidth {
        width: 100%;
        height: 100%;
        float:left;
        background-color: #FFF;
        margin: auto;
        padding: 0px;
    #body_container {
        width: 960px;
        height: 800px;
        background-color:#F1EACE;
        margin-left: auto;
        margin-right: auto;
        padding: 0px;
        margin-top: 20px;
        margin-bottom: 0px;
    #body_container_left {
        width: 580px;
        background-color:#F1EACE;
        float:left;
        margin-left: 30px;
        margin-top: 30px;
    #body_container_right {
        width: 290px;
        background-color:#F1EACE;
        float:right;
        margin-left: 30px;
        margin-right: 30px;
        margin-top: 30px;
    #left_content {
        width: 580px;
        height: 100%;
        background-color:#FFF;
        box-shadow: 3px 3px 5px #999;
        padding-top: 1px;
        padding-bottom: 8px;
        margin-bottom: 30px;
    #right_content {
        width: 290px;
        height: 100%;
        background-color:#FFF;
        box-shadow: 3px 3px 5px #999;
        padding-top: 1px;
        padding-bottom: 10px;
        margin-bottom: 30px;
    #right_content_greystrip {
        width: 290px;
        height: 24px;
        background-color:#DFDFDF;
        float:left;
    img.rightbutton {
        float:right;
    p.right_content_greystrip {
        margin-bottom: 1.2em;
        margin-top: 0em;
        font-family: Arial, Helvetica, sans-serif;
        font-size: 14px;
        text-align:right;
        padding-top: 1px;
        margin-right: 5px;
    p.right_content_greystrip a:link {
        color: #840000;
        text-decoration: none;
    p.right_content_greystrip a:visited {
        text-decoration: none;
        color: #840000;
    p.right_content_greystrip a:hover {
        color: #840000;
        text-decoration: underline;
    p.right_content_greystrip a:active {
        color: #840000;
        text-decoration: underline;
    #top-footer_container_fullwidth {
        width: 100%;
        height: 100%;
        float:left;
        background-color: #E6D69C;
        margin: auto;
        padding: 0px;
        font:Georgia, "Times New Roman", Times, serif;
        padding-top: 20px;
    #top-footer_container {
        width: 960px;
        height: 100%;
        background-color:#E6D69C;
        margin-left: auto;
        margin-right: auto;
        padding: 0px;
    #middle-footer_container_fullwidth {
        width: 100%;
        height: 100%;
        float:left;
        background-color: #F1EACE;
        margin: auto;
        padding: 0px;
        border-top: 1px solid #840000;
        border-bottom: 1px solid #840000;
        font:Georgia, "Times New Roman", Times, serif;
    #middle-footer_container {
        width: 960px;
        height: 140px;
        background-color:#F1EACE;
        margin-left: auto;
        margin-right: auto;
        padding: 0px;
    #middle-footer_container_text {
        width: 160px;
        height: 40px;
        margin-left: auto;
        margin-right: auto;
        float: left;
        padding-top: 60px;
    #middle-footer_container_awardsaccolades_img {
        width: 100px;
        height: 100px;
        margin-left: auto;
        margin-right: auto;
        float: left;
        padding-top: 20px;
    #middle-footer_container_socialmedia_img {
        width: 130px;
        height: 50px;
        margin-left: auto;
        margin-right: auto;
        float: left;
        padding-top: 48px;
    #bottom-footer_container_fullwidth {
        width: 100%;
        height: 100%;
        float:left;
        background-color: #E6D69C;
        margin: auto;
        padding: 0px;
        font:Georgia, "Times New Roman", Times, serif;
    #bottom-footer_container {
        width: 960px;
        height: 75px;
        background-color:#E6D69C;
        margin-left: auto;
        margin-right: auto;
        padding-top: 20px;

    Hi osgood_,
    Thanks so much for your generous help - this was hugely useful and much appreciated. I also managed to fix my top query via your overflow: hidden; suggestion too.
    Everything's looking great with the exception of my little ../Images/right_button.png image which isn't showing up for some reason - I ideally want it to be flush over on the right of that greystrip - any ideas?
    Thanks again
    <div id="body_container_right">
    <div id="right_content">
    <h1 class="rightcontent">Book your stay</h1>
    <img class="rightcontent" src="../Images/right_content_test.png" width="120" height="90" alt="Test" />
    <p>Check availability and book your stay in one of our luxurous individual rooms.</p>
        <div id="right_content_greystrip">
    <p class="right_content_greystrip"><a href="../Images/right_button.png"><span>Check room availability</span><img src="Images/right_button.png" width="24" height="24" alt="More" /></a></p>
      </div>
      </div>
    <div id="right_content">
    <h1 class="rightcontent">Over Canal Festival 2012</h1>
    <img class="rightcontent" src="../Images/right_content_test.png" width="120" height="90" alt="Test" />
    <p>Don’t miss the Over Canal Festival on Saturday 1 and Sunday 2 September 2012, featuring Prunella Scales and Timothy West, heritage boat processions, fun on the water, great food and drink, music and lots more!</p>
    </div>
    <div id="right_content">
    <h1 class="rightcontent">Christmas 2012 menus available now</h1>
    <img class="rightcontent" src="../Images/right_content_test.png" width="120" height="90" alt="Test" />
    <p>Turkey is banned for another year at The Wharf House, but instead you’ll find a tempting selection of courses sure to please even the pickiest eater in your party. Plus, a buffet menu is also available this festive season.</p>
    </div>
    </div>
    @charset "utf-8";
    html {
        min-height: 100%;
        margin-bottom: 1px;
    body {
        background-color: #FFFFFF;
        margin-left: 0px;
        margin-right: 0px;
        margin-top: 0px;
        margin-right: 0px;
    p {
        font:Arial, Helvetica, sans-serif;
        color: #666666;
        font-size: 14px;
        margin-bottom: 1.2em;
        margin-top: 0em;
        line-height: 1.4em;
        text-align: left;
        font-weight: normal;
        margin-left: 15px;
        margin-right: 15px;
    p.headeraddress {
        margin-bottom: 1.2em;
        margin-top: 0em;
        font:Georgia, "Times New Roman", Times, serif;
        font-size: 15px;
        text-align:left;
        color: #666666;
    p.nav {
        margin-bottom: 1.2em;
        margin-top: 0em;
        font:Georgia, "Times New Roman", Times, serif;
        font-size: 16px;
        color: #FFF;
        text-align:center;
    p.nav a:link {
        color: #FFF;
        text-decoration: none;
    p.nav a:visited {
        text-decoration: none;
        color: #FFF;
    p.nav a:hover {
        color: #FFF;
        text-decoration: underline;
    p.nav a:active {
        color: #FFF;
        text-decoration: underline;
    p.footertop {
        margin-bottom: 1.2em;
        margin-top: 0em;
        font:Georgia, "Times New Roman", Times, serif;
        font-size: 15px;
        text-align:center;
        color: #666666;
    p.footermiddle {
        margin-bottom: 1.2em;
        margin-top: 0em;
        font:Georgia, "Times New Roman", Times, serif;
        font-size: 12px;
        font-style: italic;
        text-align:right;
        color: #666666;
    img.awardsaccolades {
        display: block;
        margin-left: auto;
        margin-right: auto;
    img.socialmedia {
        display: block;
        margin-left: auto;
        margin-right: auto;
    p.footerbottom1 {
        margin-bottom: 1.2em;
        margin-top: 0em;
        font:Georgia, "Times New Roman", Times, serif;
        font-size: 15px;
        text-align:center;
        color: #666666;
    p.footerbottom2 {
        margin-bottom: 1.2em;
        margin-top: 0em;
        font:Georgia, "Times New Roman", Times, serif;
        font-size: 12px;
        font-style: italic;
        text-align:center;
        color: #666666;
    img {
        border: 0px;
    h1.leftcontent1 {
        font:Georgia, "Times New Roman", Times, serif;
        font-size: 24px;
        color: #840000;
        margin-left: 15px;
        margin-right: 15px;
        margin-bottom: 0px;
        font-weight:400;
    h1.leftcontent2 {
        font:Georgia, "Times New Roman", Times, serif;
        font-size: 20px;
        color: #666666;
        margin-left: 15px;
        margin-right: 15px;
        margin-bottom: 10px;
        font-weight:400;
    h1.rightcontent {
        font:Georgia, "Times New Roman", Times, serif;
        font-size: 20px;
        color: #666666;
        margin-left: 15px;
        margin-right: 15px;
        margin-bottom: 10px;
        font-weight:400;
    img.rightcontent {
        float:left;
        margin-left: 15px;
        margin-right: 12px;
    #youtube {
        float:left;
        margin-left: 15px;
        margin-right: 12px;
    hr.leftcontent1 {
      border: solid 1px;
      width: 520px;
      color: #840000;
      height: 1px;
      margin-left: 15px;
      margin-top: 6px;
    h2 {
        font:Georgia, "Times New Roman", Times, serif;
        font-size: 16px;
        font-style:italic;
        color: #666666;
        margin-top: 0px;
        margin-left: 15px;
        margin-right: 15px;
        margin-bottom: 15px;
        font-weight:400;
    a:link {
        color: #840000;
        text-decoration: none;
    a:visited {
        text-decoration: none;
        color: #840000;
    a:hover {
        color: #840000;
        text-decoration: underline;
    a:active {
        color: #666666;
        text-decoration: underline;
    #logo_address_container_fullwidth {
        width: 100%;
        height: 100%;
        float:left;
        background-color:#F1EACE;
        margin: auto;
        padding-top: 35px;
    #logo_address_container {
        width: 960px;
        height: 74px;
        background-color:#F1EACE;
        margin-left: auto;
        margin-right: auto;
        padding: 0px;
    #logo_container {
        width: 359px;
        height: 41px;
        float:left;
        padding-left: 20px;
    #address_container {
        width: 561px;
        height: 20px;
        float:left;
        padding-left: 20px;
        margin-top: 14px;
    #nav_container_fullwidth {
        width: 100%;
        float:left;
        background-color:#840000;
        margin: auto;
        padding: 0px;
    #nav_container {
        width: 960px;
        height: 30px;
        background-color:#840000;
        margin-left: auto;
        margin-right: auto;
        padding-top: 6px;
    #header_image_container_fullwidth {
        width: 100%;
        height: 350px;
        float:left;
        background-color:#F1EACE;
        margin: auto;
        padding: 0px;
    #header_image_container {
        width: 1100px;
        height: 100%;
        background-color:#F1EACE;
        margin-left: auto;
        margin-right: auto;
        padding: 0px;
    #body_container_fullwidth {
        width: 100%;
        height: 100%;
        float:left;
        background-color: #FFF;
        margin: auto;
        padding: 0px;
    #body_container {
        width: 960px;
        overflow: hidden;
        background-color:#F1EACE;
        margin-left: auto;
        margin-right: auto;
        padding: 0px;
        margin-top: 20px;
        margin-bottom: 0px;
    #body_container_left {
        width: 580px;
        background-color:#F1EACE;
        float:left;
        margin-left: 30px;
        margin-top: 30px;
    #body_container_right {
        width: 290px;
        background-color:#F1EACE;
        float:right;
        margin-left: 30px;
        margin-right: 30px;
        margin-top: 30px;
    #left_content {
        width: 580px;
        overflow: hidden;
        background-color:#FFF;
        box-shadow: 3px 3px 5px #999;
        padding-top: 1px;
        padding-bottom: 8px;
        margin-bottom: 30px;
    #right_content {
        width: 290px;
        height: 100%;
        background-color:#FFF;
        box-shadow: 3px 3px 5px #999;
        padding-top: 1px;
        padding-bottom: 10px;
        margin-bottom: 30px;
    #right_content_greystrip {
        width: 290px;
        background-color:#DFDFDF;
        float: left;
    #right_content_greystrip span {
        float: left;
        width: 230px;
        display: block;
        padding: 3px 0 0 0;
    #right_content_greystrip img {
        float: right;
    p.right_content_greystrip {
        margin-bottom: 1.2em;
        margin-top: 0em;
        font-family: Arial, Helvetica, sans-serif;
        font-size: 14px;
        text-align:right;
        padding-top: 1px;
        margin-right: 5px;
    p.right_content_greystrip a:link {
        color: #840000;
        text-decoration: none;
    p.right_content_greystrip a:visited {
        text-decoration: none;
        color: #840000;
    p.right_content_greystrip a:hover {
        color: #840000;
        text-decoration: underline;
    p.right_content_greystrip a:active {
        color: #840000;
        text-decoration: underline;
    #top-footer_container_fullwidth {
        width: 100%;
        height: 100%;
        float:left;
        background-color: #E6D69C;
        margin: auto;
        padding: 0px;
        font:Georgia, "Times New Roman", Times, serif;
        padding-top: 20px;
    #top-footer_container {
        width: 960px;
        height: 100%;
        background-color:#E6D69C;
        margin-left: auto;
        margin-right: auto;
        padding: 0px;
    #middle-footer_container_fullwidth {
        width: 100%;
        height: 100%;
        float:left;
        background-color: #F1EACE;
        margin: auto;
        padding: 0px;
        border-top: 1px solid #840000;
        border-bottom: 1px solid #840000;
        font:Georgia, "Times New Roman", Times, serif;
    #middle-footer_container {
        width: 960px;
        height: 140px;
        background-color:#F1EACE;
        margin-left: auto;
        margin-right: auto;
        padding: 0px;
    #middle-footer_container_text {
        width: 160px;
        height: 40px;
        margin-left: auto;
        margin-right: auto;
        float: left;
        padding-top: 60px;
    #middle-footer_container_awardsaccolades_img {
        width: 100px;
        height: 100px;
        margin-left: auto;
        margin-right: auto;
        float: left;
        padding-top: 20px;
    #middle-footer_container_socialmedia_img {
        width: 130px;
        height: 50px;
        margin-left: auto;
        margin-right: auto;
        float: left;
        padding-top: 48px;
    #bottom-footer_container_fullwidth {
        width: 100%;
        height: 100%;
        float:left;
        background-color: #E6D69C;
        margin: auto;
        padding: 0px;
        font:Georgia, "Times New Roman", Times, serif;
    #bottom-footer_container {
        width: 960px;
        height: 75px;
        background-color:#E6D69C;
        margin-left: auto;
        margin-right: auto;
        padding-top: 20px;

  • GRC 10.0 - Insert a new field on the RISK/OPPORTUNITY

    Hello All,
    I have an activity to enhance the component below, to insert a new field on there.
    The problem is that I don't know how to make it integrated with the save activity.
    Embebbed with this component, I have the componet parent grrm_wd_rnp as shown below:
    This component is called by the component POWL_UI_COMP. This screen below shows how this initial screen looks like:
    Anybody knows how to implement this? It's confusing working with too many standard components conecting each other.
    Regards,
    Ricardo

    Heinz,
    You may investigate logic using UNIONs and a manual tabular form.
    Something like:
    --get all records above new row
    select apex_item... column1
    ,apex_item... column2
    from yourtable
    where <logic to limit rows above new record>
    union
    --get the new row
    select apex_item... column1
    ,apex_item... column2
    from dual
    where :REQUEST = 'ADDROW'
    union
    --get every row not in the top query
    select apex_item... column1
    ,apex_item... column2
    from yourtable
    where <logic to pull all records not pulled above new record>
    For this to work you'll need to add your own "Add Row" button and associate it with a branch. Notice the select between the two unions in the above query is a select against dual. This will be your new record when pressing your "Add Row" button (:REQUEST = 'ADDROW').
    The following how-to link is a reference for some of the logic you'll need when creating a manual tabular form.
    http://www.oracle.com/technology/products/database/application_express/howtos/tabular_form.html#MANUAL
    Good Luck,
    Todd

  • Pivot not working; Analytics question

    I got a lot done this past weekend on tough query for me but now have more questions. You must run the top query to understand the understand the second.
    Background:
    This is a period to date report which includes amounts from beginning of the year as well as last year.
    My example Report is for Period 9 which begins on Aug 24, 2009
    Period has 5 weeks (Most periods have 4) ;
    Also if period is requested in Week 3 then only weeks 1 and 2 will be reflected on report
    The report looks like this: (Data provided should produce these numbers except for maybe the YTD column.
                 WEEK1       WEEK2           WEEK3         WEEK4             WEEK5       Period-to-date          Year-to-date
    Net - Landau     11,485.79   11,416.60      11,609.01     11,049.76      12,867.10      58,428.00             454,231.37      
    Net - AW     0.00               0.00          0.00        0.00                   0.00          0.00              0.00
    Net - LJS     0.00                   0.00           0.00         0.00           0.00          0.00            0.00
    Net - TB     7,118.17     7,228.13    7,657.94      7,699.53           7,958.53      37,662.00            306,115.59      
    Total Net     18,603.96    18,644.73      19,266.95     18,749.29         20,825.63      96,091.00            760,346.96      
    Last Year Sales     23,515.95    24,244.37       23,962.74    23,134.79      24,440.87      119,299.00           856,363.36      
    Increase     (4,911.99)  (5,599.64)      (4,695.79)  (4,385.50)           (3,615.24)     (23,208.00)           (96,016.40)     
    Last year
      Next Week     24,244.37    23,962.74       23,134.79    24,440.87      23,055.87      118,839.00           879,419.23      --===== Current Year Dates
    Beginning of period: (BOP) Mon Aug 24
    Week 1: Mon Aug 24 - Aug 30
    Week 2: Mon Aug 11 - Sept 6
    Week 3: Mon Sep 7 - Sept 13
    Week 4: Mon Sept 14 - Sept 20
    Week 5: Mon Sept 21 - Sept 27
    Beginning of fiscal year( BOY) = '28-Dec-08'
    --===== Last Year Dates
    Beginning of period: (BOP_LY) Mon Aug 25
    Week 1: Mon Aug 25 - Aug 31
    Week 2: Mon Aug 1 - Sept 7
    Week 3: Mon Sep 8 - Sept 14
    Week 4: Mon Sept 15 - Sept 21
    Week 5: Mon Sept 22 - Sept 28
    Beginning of fiscal year( BOY) = '31-Dec-07'
    My challenge over weekend was to get entire year of data vs. just the period data.
    There are 7 columns on this report. 5 weeks of period, PeriodToDate (total of the weeks) and YearToDate (PeriodToDate + Sum of all data from beginning of year to the end of the previous period.
    I'm not really concerned with the PTD, the program can handle that. I got the BOY date with the following code:
    All data is summed for the week and grouped by storeid and TRUNC(date, 'IW') which is the Monday of each week.
    of each week. (The resultset contains data for 2 stores instead of 1. This is there only to make sure my query was filtering correctly)
    drop table my_csh_main;
    CREATE TABLE MY_CSH_MAIN
       (     "FK_STR_MAIN_ID" NUMBER,
         "BUSI_DATE" DATE,
         "CONF_NUMB2" NUMBER,
         "CONF_NUMB49" NUMBER,
         "CONF_NUMB44" NUMBER,
         "CONF_NUMB3" NUMBER,
         "CONF_NUMB4" NUMBER,
         "CONF_NUMB38" NUMBER,
         "CONF_NUMB56" NUMBER
    REM INSERTING into MY_CSH_MAIN
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (141,to_date('28-AUG-08','DD-MON-RR'),22103.69,0,0,119,0,4605.21,0);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (141,to_date('27-AUG-09','DD-MON-RR'),18081.37,0,0,0,0,3533.45,0);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (141,to_date('17-SEP-09','DD-MON-RR'),18211.29,0,0,0,0,3806.32,0);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (221,to_date('04-SEP-08','DD-MON-RR'),24244.37,0,0,284.94,0,0,9395.63);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (221,to_date('03-SEP-09','DD-MON-RR'),18644.73,0,0,85.48,0,0,7228.13);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (141,to_date('24-SEP-09','DD-MON-RR'),16809.21,0,0,64.99,0,3014.61,0);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (221,to_date('25-SEP-08','DD-MON-RR'),24440.87,0,0,0,0,0,9469.64);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (221,to_date('28-AUG-08','DD-MON-RR'),23515.95,0,0,0,80.38,0,9379.9);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (221,to_date('24-SEP-09','DD-MON-RR'),20825.63,0,0,73.97,0,0,7958.53);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (221,to_date('17-SEP-09','DD-MON-RR'),18749.29,0,0,0,0,0,7699.53);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (141,to_date('11-SEP-08','DD-MON-RR'),22839.3,0,0,206.39,116.74,4493.28,0);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (141,to_date('04-SEP-08','DD-MON-RR'),22627.74,0,0,279.98,0,4423.83,0);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (221,to_date('27-AUG-09','DD-MON-RR'),18603.96,0,0,81.25,0,0,7118.17);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (221,to_date('11-SEP-08','DD-MON-RR'),23962.74,0,0,153.1,0,0,9335.35);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (221,to_date('18-SEP-08','DD-MON-RR'),23134.79,0,0,44.12,0,0,8978.87);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (141,to_date('25-SEP-08','DD-MON-RR'),24950.45,0,0,129.98,0,5330.22,0);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (221,to_date('10-SEP-09','DD-MON-RR'),19266.95,0,0,0,0,0,7657.94);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (141,to_date('03-SEP-09','DD-MON-RR'),17183.25,0,0,0,0,3487.12,0);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (141,to_date('18-SEP-08','DD-MON-RR'),21372.82,0,0,0,0,4546.15,0);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (141,to_date('10-SEP-09','DD-MON-RR'),17688.41,0,0,113.12,0,3424.17,0);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (141,to_date('31-DEC-08','DD-MON-RR'),611016.24,0,0,1276.62,724.96,122236.02,0);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (221,to_date('31-DEC-08','DD-MON-RR'),667612.63,0,0,1018.81,0,0,269777.87);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (141,to_date('02-JAN-08','DD-MON-RR'),1676737.13,0,0,5652.47,3850.68,345971.1,500.5);
    Insert into MY_CSH_MAIN (FK_STR_MAIN_ID,BUSI_DATE,CONF_NUMB2,CONF_NUMB49,CONF_NUMB44,CONF_NUMB3,CONF_NUMB4,CONF_NUMB38,CONF_NUMB56) values (221,to_date('02-JAN-08','DD-MON-RR'),1786451.11,0,0,3167.61,175.38,0,788438.73);
      CREATE TABLE  LANDAU_REPORT_STORES
       (     "COMPANYNAME" CHAR(40 BYTE),
         "DISTRICTNAME" VARCHAR2(50 BYTE),
         "STOREID" NUMBER(4,0) NOT NULL ENABLE,
         "STORENAME" VARCHAR2(70 BYTE),
         "STORENBR" CHAR(4 BYTE) NOT NULL ENABLE
    REM INSERTING into LANDAU_REPORT_STORES
    Insert into LANDAU_REPORT_STORES (COMPANYNAME,DISTRICTNAME,STOREID,STORENAME,STORENBR) values ('Landau                                  ','DIST 10',64,'N_Main','0004');
    Insert into LANDAU_REPORT_STORES(COMPANYNAME,DISTRICTNAME,STOREID,STORENAME,STORENBR) values ('Landau                                  ','DIST 10',65,'Belvidere','0005');
    Insert into LANDAU_REPORT_STORES(COMPANYNAME,DISTRICTNAME,STOREID,STORENAME,STORENBR) values ('Landau                                  ','DIST 10',104,'Mulford','0032');
    Insert into LANDAU_REPORT_STORES(COMPANYNAME,DISTRICTNAME,STOREID,STORENAME,STORENBR) values ('Landau                                  ','DIST 50',141,'Charleston','0043');
    Insert into LANDAU_REPORT_STORES(COMPANYNAME,DISTRICTNAME,STOREID,STORENAME,STORENBR) values ('Landau                                  ','DIST 10',61,'Kilburn','0002');
    Insert into LANDAU_REPORT_STORES(COMPANYNAME,DISTRICTNAME,STOREID,STORENAME,STORENBR) values ('Landau                                  ','DIST 10',62,'11th_St','0003');
       with WeeklyTotals as
       ( select                           StoreId
                                         , week_date
                                         , net_sales
                                         , ljs_food_sales
                                         , total_drink_sales
                                         , net_food
                                         , CASE
                                              WHEN net_food is null  then 0
                                              WHEN net_food  = 0  then 0
                                              ELSE Ljs_food_sales / net_food
                                           END as LJS_Percent
                                         , CASE
                                              WHEN net_food is null  then 0
                                              WHEN net_food = 0  then 0
                                              else total_drink_sales * (ljs_food_sales / net_food)
                                           END as LJS_Drinks
                                         , aw_sales
                                         , tb_sales
              FROM                            (Select fk_str_main_id as StoreId,
                                                                               trunc(csh.busi_date, 'IW') as week_date,
                                                                         sum(csh.conf_numb2) As net_sales,
                                                                         sum(conf_numb49) as ljs_food_sales,
                                                                         sum(conf_numb44)  As total_drink_sales,
                                                                         sum(csh.conf_numb2) - sum(CONF_NUMB44) - sum(conf_numb3) - sum(conf_numb4) AS net_food,
                                                                         sum(conf_numb38) As aw_sales,
                                                                         sum(conf_numb56)  as tb_sales
                                                     from my_csh_main csh
                                                     WHERE BUSI_DATE BETWEEN  TO_DATE( '28-Dec-08' ,'DD-MON-YY') AND  TO_DATE( '27-SEP-09' ,'DD-MON-YY')
                                                    and fk_str_main_id in (141, 221)
                                                    GROUP BY CSH.FK_STR_MAIN_ID,    trunc(csh.busi_date, 'IW')
       ,  WeeklyFoodSalesLY as
        SELECT    fk_str_main_id AS storeid
               ,  TRUNC(busi_date, 'iw') week_date
               ,  SUM(csh.conf_numb2) AS net_sales
        FROM   my_csh_main csh
        WHERE busi_date BETWEEN   to_date('31-DEc-07', 'dd-Mon-yy')  and  to_date('28-Sep-08', 'dd-Mon-yy')
        GROUP BY fk_str_main_id, TRUNC(busi_date, 'iw')
      , StoreDetails  AS
             select * from LANDAU_REPORT_STORES where STORENAME NOT like  '%CLOSED%'  order by DistrictNAme, StoreNbr
       Select 
                 foods.storeid
              ,   CASE
                   WHEN   to_date(Foods.week_date, 'dd-Mon-yy')  =  to_date('24-AUG-09', 'dd-Mon-yy')  then 1
                   WHEN   to_date(Foods.week_date, 'dd-Mon-yy')  =  to_date('24-AUG-09', 'dd-Mon-yy') + 7 then 2
                   WHEN   to_date(Foods.week_date, 'dd-Mon-yy')  =  to_date('24-AUG-09', 'dd-Mon-yy') + 14 then 3
                   WHEN   to_date(Foods.week_date, 'dd-Mon-yy')  =  to_date('24-AUG-09','dd-Mon-yy') + 21 then 4
                   WHEN   to_date(Foods.week_date, 'dd-Mon-yy')  =  to_date('24-AUG-09', 'dd-Mon-yy') + 28 then 5
                   ELSE  0
             end as WeekNBr
        ,   foods.week_date  as CurrWeekDate
        ,   foodsLY.week_date as LastYearWEekDate   
        ,   ROUND(NVL(foods.net_sales - (aw_sales + tb_sales + ljs_drinks + ljs_food_sales ), 0), 2) as Landau_Net_Sales
        ,   ROUND(NVL(aw_sales, 0), 2) as aw_sales
        ,   ROUND(NVL(tb_sales, 0), 2) as tb_sales
        ,   ROUND(NVL(ljs_drinks + ljs_food_sales, 0),2)    as ljs_net_sales
        ,   ROUND(NVL(foods.Net_Sales, 0), 2) as net_sales
        --==
        -- Last Year Sales and Last Year Next Year Sales
       --==
    ,    ROUND(NVL(foodsLY.Net_Sales, 0),2)    as    WTDLYNetSales
    ,    ROUND(NVL(Foods.Net_Sales -  FoodsLY.Net_Sales, 0),2)  as    WTDSalesIncrease
    -- ,    ROUND(NVL(FoodsLY_NextWeek.Net_Sales, 0), 2)          as    WTDFoodsSalesLY 
    ,   stores.*
    from WEeklyTotals Foods 
    LEFT OUTER JOIN Weeklyfoodsalesly foodsly ON foodsly.storeid = foods.storeid
                                              AND foodsly.week_date = DECODE(foods.week_date,
                                                                             to_date('24-AUG-09', 'dd-Mon-yy') ,       to_date('25-AUG-08', 'dd-Mon-yy') ,
                                                                             to_date('24-AUG-09', 'dd-Mon-yy')  + 7,   to_date('25-AUG-08', 'dd-Mon-yy') + 7,
                                                                             to_date('24-AUG-09', 'dd-Mon-yy')  + 14,  to_date('25-AUG-08', 'dd-Mon-yy') + 14,
                                                                             to_date('24-AUG-09', 'dd-Mon-yy')  + 21,  to_date('25-AUG-08', 'dd-Mon-yy') + 21,
                                                                             to_date('24-AUG-09', 'dd-Mon-yy')  + 28,  to_date('25-AUG-08', 'dd-Mon-yy') + 28)
    LEFT OUTER  JOIN  StoreDetails             stores  ON     stores.storeid   = Foods.storeid;one exception. In a With statement, I get a recordset containing all of last years data. I could not figure out the Pivot
    to get the Last Year Next Week . That means next week, one year ago. I pulled out a snippet to work with but couldn't get it
    to work:
    The problem came when I tried to pivot the Last year sales. I pulled this snippet out to test with but couldn't make it work.
    with   WeeklyFoodSalesLY  as
    (         SELECT  fk_str_main_id AS storeid
                 ,   TRUNC(busi_date, 'iw') week_date
                 ,   sum(conf_numb2)   conf_numb2
               FROM  my_csh_main csh    
               WHERE busi_date BETWEEN   to_date('31-dec-07', 'dd-Mon-yy')  and  to_date('28-Sep-08', 'dd-Mon-yy') + 7
               and fk_str_main_id = 141  
               GROUP BY  fk_str_main_id , TRUNC(busi_date, 'iw')      
    ,  sales_ly as
    (    SELECT      storeid
                    , week_date
                    , sum(conf_numb2) as net_sales
          from WeeklyFoodSalesLY
          WHERE week_date BETWEEN   to_date('25-Aug-08', 'dd-Mon-yy')  and  to_date('28-Sep-08', 'dd-Mon-yy') 
          GROUP BY  storeid , week_date    
          UNION ALL
          SELECT      storeid
                    , week_date
                    , sum(conf_numb2) as net_sales
          from WeeklyFoodSalesLY
          WHERE week_date BETWEEN   to_date('25-Aug-08', 'dd-Mon-yy') + 7   and  to_date('28-Sep-08', 'dd-Mon-yy') + 7
          GROUP BY  storeid , week_date
          UNION ALL
          SELECT      storeid
                    , week_date
                    , sum(conf_numb2) as net_sales
          from WeeklyFoodSalesLY
          WHERE week_date < to_date('25-Aug-08', 'dd-Mon-yy') 
          GROUP BY  storeid , week_date
    ,  pivoted_sales_ly as
    (    SELECT          storeid
                         week_date
                    ,    MAX(DECODE(week_date, to_date('25-Aug-08', 'dd-Mon-yy'),          net_sales))        as lastyear
                    ,    MAX(DECODE(week_date, to_date('25-Aug-08', 'dd-Mon-yy') + 7,      net_sales))        as lastyearnextweek
                    ,    MAX(DECODE(week_date, to_date('31-dec-07', 'dd-Mon-yy'),          net_sales))        as lastyeartotal
          from sales_ly
          GROUP BY  storeid, week_date
    Select *
    from pivoted_sales_ly;  What am i dont wrong here? Once I get this I can work back into the original query.
    Analytics:
    Boneist gave me some code to try last week:
    Combining refCursors  and Summing
    that created the PTD column.
    I could never get it to work because I was tweaking so much with the Query but is there a way to get the PTD without
    having to add an extra PTD column for each week.
    One other thing:
    I would like to know how to use analytics to roll up report by division into a different cursor.
    Edited by: TheHTMLDJ on Oct 26, 2009 4:50 AM
    Edited by: TheHTMLDJ on Oct 26, 2009 4:59 AM

    TheHTMLDJ wrote:
    The report looks like this: (Data provided should produce these numbers except for maybe the YTD column.With the data you provided, I managed to produce the expected output for storeid 221, barring the YTD column, which had the wrong values. I had to make up the "next week" row for the previous year for storeid 221, btw:
    WITH weekly_values AS (SELECT fk_str_main_id as storeid,
                                  TRUNC(csh.busi_date, 'IW') AS week_date,
                                  NVL(SUM(csh.conf_numb2), 0) AS net_sales,
                                  NVL(SUM(conf_numb49), 0) AS ljs_food_sales,
                                  NVL(SUM(conf_numb44), 0) AS total_drink_sales,
                                  NVL(SUM(csh.conf_numb2) - SUM(conf_numb44)
                                                          - SUM(conf_numb3)
                                                          - SUM(conf_numb4), 0) AS net_food,
                                  NVL(SUM(conf_numb38), 0) AS aw_sales,
                                  NVL(SUM(conf_numb56), 0) AS tb_sales
                           FROM   my_csh_main csh
                           WHERE  (busi_date BETWEEN TRUNC(:v_bop, 'iy') AND TRUNC(:v_bop, 'iw') + 7*(:v_num_weeks - 1) + 6
                                   OR
                                   busi_date BETWEEN TRUNC(:v_bop_ly, 'iy') AND TRUNC(:v_bop_ly, 'iw') + 7*:v_num_weeks  + 6)
                           AND    fk_str_main_id IN (141, 221)
                           GROUP BY csh.fk_str_main_id,
                                    TRUNC(csh.busi_date, 'IW')),
         weekly_totals AS (SELECT storeid,
                                  week_date,
                                  net_sales,
                                  ljs_food_sales,
                                  total_drink_sales,
                                  net_food,
                                  CASE WHEN nvl(net_food, 0) = 0 then 0
                                       ELSE ljs_food_sales / net_food
                                  END AS ljs_percent,
                                  CASE WHEN nvl(net_food, 0) = 0 then 0
                                       ELSE total_drink_sales * (ljs_food_sales / net_food)
                                  END AS ljs_drinks,
                                  aw_sales,
                                  tb_sales,
                                  net_sales - aw_sales
                                            - tb_sales
                                            - ljs_food_sales
                                            - CASE WHEN nvl(net_food, 0) = 0 then 0
                                                   ELSE total_drink_sales * (ljs_food_sales / net_food)
                                              END AS landau_net_sales
                           FROM   weekly_values),
         week_tots_ytd AS (SELECT storeid,
                                  week_date,
                                  net_sales,
                                  ljs_food_sales,
                                  total_drink_sales,
                                  net_food,
                                  ljs_drinks,
                                  aw_sales,
                                  tb_sales,
                                  landau_net_sales,
                                  SUM(decode(week_date, TRUNC(:v_bop_ly, 'iw') + 7*:v_num_weeks, NULL, landau_net_sales)) OVER (PARTITION BY storeid,
                                                                                                                                             trunc(week_date, 'iy')) lns_ytd,
                                  SUM(decode(week_date, TRUNC(:v_bop_ly, 'iw') + 7*:v_num_weeks, NULL, aw_sales)) OVER (PARTITION BY storeid,
                                                                                                                                     trunc(week_date, 'iy')) aws_ytd,
                                  SUM(decode(week_date, TRUNC(:v_bop_ly, 'iw') + 7*:v_num_weeks, NULL, ljs_food_sales)) OVER (PARTITION BY storeid,
                                                                                                                                           trunc(week_date, 'iy')) ljsf_ytd,
                                  SUM(decode(week_date, TRUNC(:v_bop_ly, 'iw') + 7*:v_num_weeks, NULL, tb_sales)) OVER (PARTITION BY storeid,
                                                                                                                                     trunc(week_date, 'iy')) tbs_ytd,
                                  SUM(decode(week_date, TRUNC(:v_bop_ly, 'iw') + 7*:v_num_weeks, NULL, net_sales)) OVER (PARTITION BY storeid,
                                                                                                                                      trunc(week_date, 'iy')) net_ytd,
                                  SUM(net_sales) OVER (PARTITION BY storeid,
                                                                    trunc(week_date, 'iy')) full_net_ytd,
                                  SUM(landau_net_sales) OVER (PARTITION BY storeid,
                                                                           CASE WHEN week_date between TRUNC(:v_bop, 'iw') and TRUNC(:v_bop, 'iw') + 7*(:v_num_weeks -1) THEN 1
                                                                                WHEN week_date between TRUNC(:v_bop_ly, 'iw') and TRUNC(:v_bop_ly, 'iw') + 7*(:v_num_weeks -1) THEN 2
                                                                           END) lns_ptd,
                                  SUM(aw_sales) OVER (PARTITION BY storeid,
                                                                   CASE WHEN week_date between TRUNC(:v_bop, 'iw') and TRUNC(:v_bop, 'iw') + 7*(:v_num_weeks -1) THEN 1
                                                                        WHEN week_date between TRUNC(:v_bop_ly, 'iw') and TRUNC(:v_bop_ly, 'iw') + 7*(:v_num_weeks -1) THEN 2
                                                                   END) aws_ptd,
                                  SUM(ljs_food_sales) OVER (PARTITION BY storeid,
                                                                         CASE WHEN week_date between TRUNC(:v_bop, 'iw') and TRUNC(:v_bop, 'iw') + 7*(:v_num_weeks -1) THEN 1
                                                                              WHEN week_date between TRUNC(:v_bop_ly, 'iw') and TRUNC(:v_bop_ly, 'iw') + 7*(:v_num_weeks -1) THEN 2
                                                                         END) ljsf_ptd,
                                  SUM(tb_sales) OVER (PARTITION BY storeid,
                                                                   CASE WHEN week_date between TRUNC(:v_bop, 'iw') and TRUNC(:v_bop, 'iw') + 7*(:v_num_weeks -1) THEN 1
                                                                        WHEN week_date between TRUNC(:v_bop_ly, 'iw') and TRUNC(:v_bop_ly, 'iw') + 7*(:v_num_weeks -1) THEN 2
                                                                   END) tbs_ptd,
                                  SUM(net_sales) OVER (PARTITION BY storeid,
                                                                    CASE WHEN week_date between TRUNC(:v_bop, 'iw') and TRUNC(:v_bop, 'iw') + 7*(:v_num_weeks -1) THEN 1
                                                                         WHEN week_date between TRUNC(:v_bop_ly, 'iw') and TRUNC(:v_bop_ly, 'iw') + 7*(:v_num_weeks-1) THEN 2
                                                                    END) net_ptd,
                                  LEAD(net_sales) OVER (PARTITION BY storeid,
                                                                     trunc(week_date, 'iy')
                                                        ORDER BY week_date) next_week_net_sales
                           FROM   weekly_totals),
                 foods AS (Select storeid,
                                  CASE WHEN week_date in (:v_bop, :v_bop_ly) then 1
                                       WHEN week_date in (:v_bop + 7, :v_bop_ly + 7) then 2
                                       WHEN week_date in (:v_bop + 14, :v_bop_ly + 14) then 3
                                       WHEN week_date in (:v_bop + 21, :v_bop_ly + 21) then 4
                                       WHEN week_date in (:v_bop + 28, :v_bop_ly + 28) then 5
                                  END AS week_number,
                                  week_date,
                                  ROUND(net_sales - (aw_sales + tb_sales + ljs_drinks + ljs_food_sales), 2) AS landau_net_sales,
                                  ROUND(aw_sales, 2) AS aw_sales,
                                  ROUND(tb_sales, 2) AS tb_sales,
                                  ROUND(ljs_drinks + ljs_food_sales, 2) AS ljs_net_sales,
                                  ROUND(net_sales, 2) AS net_sales,
                                  ROUND(lns_ytd, 2) AS lns_ytd,
                                  ROUND(aws_ytd, 2) AS aws_ytd,
                                  ROUND(ljsf_ytd, 2) AS ljsf_ytd,
                                  ROUND(tbs_ytd, 2) AS tbs_ytd,
                                  ROUND(net_ytd, 2) AS net_ytd,
                                  ROUND(full_net_ytd, 2) AS full_net_ytd,
                                  ROUND(lns_ptd, 2) AS lns_ptd,
                                  ROUND(aws_ptd, 2) AS aws_ptd,
                                  ROUND(ljsf_ptd, 2) AS ljsf_ptd,
                                  ROUND(tbs_ptd, 2) AS tbs_ptd,
                                  ROUND(net_ptd, 2) AS net_ptd,
                                  ROUND(next_week_net_sales, 2) AS next_week_net_sales,
                                  SUM(ROUND(next_week_net_sales, 2)) OVER (PARTITION BY storeid,
                                                                                       TRUNC(week_date, 'iy')) nwns_ptd
                           FROM   week_tots_ytd
                           WHERE  (week_date BETWEEN TRUNC(:v_bop, 'iw') AND TRUNC(:v_bop, 'iw') + 7*(:v_num_weeks - 1)
                                   OR
                                   week_date BETWEEN TRUNC(:v_bop_ly, 'iw') AND TRUNC(:v_bop_ly, 'iw') + 7*(:v_num_weeks - 1))),
         pivoted_foods AS (SELECT storeid,
                                  week_number,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop, 'iy'), landau_net_sales)) landau_net_sales,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop, 'iy'), aw_sales)) aw_sales,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop, 'iy'), tb_sales)) tb_sales,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop, 'iy'), ljs_net_sales)) ljs_net_sales,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop, 'iy'), net_sales)) net_sales,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop, 'iy'), lns_ytd)) lns_ytd,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop, 'iy'), aws_ytd)) aws_ytd,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop, 'iy'), ljsf_ytd)) ljsf_ytd,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop, 'iy'), tbs_ytd)) tbs_ytd,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop, 'iy'), net_ytd)) net_ytd,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop, 'iy'), full_net_ytd)) full_net_ytd,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop, 'iy'), lns_ptd)) lns_ptd,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop, 'iy'), aws_ptd)) aws_ptd,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop, 'iy'), ljsf_ptd)) ljsf_ptd,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop, 'iy'), tbs_ptd)) tbs_ptd,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop, 'iy'), net_ptd)) net_ptd,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop_ly, 'iy'), net_sales)) ly_net_sales,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop_ly, 'iy'), net_ytd)) ly_net_ytd,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop_ly, 'iy'), net_ptd)) ly_net_ptd,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop_ly, 'iy'), next_week_net_sales)) ly_next_week_net_sales,
                                  MAX(DECODE(TRUNC(week_date, 'iy'), TRUNC(:v_bop_ly, 'iy'), nwns_ptd)) ly_nwns_ptd
                           FROM   foods
                           GROUP BY storeid,
                                    week_number),
          storedetails AS (SELECT companyname,
                                  districtname,
                                  storeid,
                                  storename,
                                  storenbr
                           FROM   landau_report_stores
                           WHERE  UPPER(storename) NOT LIKE  '%CLOSED%' 
                           ORDER BY districtname, storenbr),
                 dummy AS (SELECT level col1
                           FROM   dual
                           CONNECT BY level <= 8)
    SELECT pf.storeid,
           DECODE(dummy.col1, 1, 'Net - Landau',
                              2, 'Net - AW',
                              3, 'Net - LJS',
                              4, 'Net - TB',
                              5, 'Total Net',
                              6, 'Last Year Sales',
                              7, 'Increase',
                              8, 'Last Year Next Week') category,
           SUM(CASE WHEN pf.week_number = 1 AND dummy.col1 = 1 THEN pf.landau_net_sales
                    WHEN pf.week_number = 1 AND dummy.col1 = 2 THEN pf.aw_sales
                    WHEN pf.week_number = 1 AND dummy.col1 = 3 THEN pf.ljs_net_sales
                    WHEN pf.week_number = 1 AND dummy.col1 = 4 THEN pf.tb_sales
                    WHEN pf.week_number = 1 AND dummy.col1 = 5 THEN pf.net_sales
                    WHEN pf.week_number = 1 AND dummy.col1 = 6 THEN pf.ly_net_sales
                    WHEN pf.week_number = 1 AND dummy.col1 = 7 THEN pf.net_sales - pf.ly_net_sales
                    WHEN pf.week_number = 1 AND dummy.col1 = 8 THEN pf.ly_next_week_net_sales
           END) week1,
           SUM(CASE WHEN pf.week_number = 2 AND dummy.col1 = 1 THEN pf.landau_net_sales
                    WHEN pf.week_number = 2 AND dummy.col1 = 2 THEN pf.aw_sales
                    WHEN pf.week_number = 2 AND dummy.col1 = 3 THEN pf.ljs_net_sales
                    WHEN pf.week_number = 2 AND dummy.col1 = 4 THEN pf.tb_sales
                    WHEN pf.week_number = 2 AND dummy.col1 = 5 THEN pf.net_sales
                    WHEN pf.week_number = 2 AND dummy.col1 = 6 THEN pf.ly_net_sales
                    WHEN pf.week_number = 2 AND dummy.col1 = 7 THEN pf.net_sales - pf.ly_net_sales
                    WHEN pf.week_number = 2 AND dummy.col1 = 8 THEN pf.ly_next_week_net_sales
           END) week2,
           SUM(CASE WHEN pf.week_number = 3 AND dummy.col1 = 1 THEN pf.landau_net_sales
                    WHEN pf.week_number = 3 AND dummy.col1 = 2 THEN pf.aw_sales
                    WHEN pf.week_number = 3 AND dummy.col1 = 3 THEN pf.ljs_net_sales
                    WHEN pf.week_number = 3 AND dummy.col1 = 4 THEN pf.tb_sales
                    WHEN pf.week_number = 3 AND dummy.col1 = 5 THEN pf.net_sales
                    WHEN pf.week_number = 3 AND dummy.col1 = 6 THEN pf.ly_net_sales
                    WHEN pf.week_number = 3 AND dummy.col1 = 7 THEN pf.net_sales - pf.ly_net_sales
                    WHEN pf.week_number = 3 AND dummy.col1 = 8 THEN pf.ly_next_week_net_sales
           END) week3,
           SUM(CASE WHEN pf.week_number = 4 AND dummy.col1 = 1 THEN pf.landau_net_sales
                    WHEN pf.week_number = 4 AND dummy.col1 = 2 THEN pf.aw_sales
                    WHEN pf.week_number = 4 AND dummy.col1 = 3 THEN pf.ljs_net_sales
                    WHEN pf.week_number = 4 AND dummy.col1 = 4 THEN pf.tb_sales
                    WHEN pf.week_number = 4 AND dummy.col1 = 5 THEN pf.net_sales
                    WHEN pf.week_number = 4 AND dummy.col1 = 6 THEN pf.ly_net_sales
                    WHEN pf.week_number = 4 AND dummy.col1 = 7 THEN pf.net_sales - pf.ly_net_sales
                    WHEN pf.week_number = 4 AND dummy.col1 = 8 THEN pf.ly_next_week_net_sales
           END) week4,
           SUM(CASE WHEN pf.week_number = 5 AND dummy.col1 = 1 THEN pf.landau_net_sales
                    WHEN pf.week_number = 5 AND dummy.col1 = 2 THEN pf.aw_sales
                    WHEN pf.week_number = 5 AND dummy.col1 = 3 THEN pf.ljs_net_sales
                    WHEN pf.week_number = 5 AND dummy.col1 = 4 THEN pf.tb_sales
                    WHEN pf.week_number = 5 AND dummy.col1 = 5 THEN pf.net_sales
                    WHEN pf.week_number = 5 AND dummy.col1 = 6 THEN pf.ly_net_sales
                    WHEN pf.week_number = 5 AND dummy.col1 = 7 THEN pf.net_sales - pf.ly_net_sales
                    WHEN pf.week_number = 5 AND dummy.col1 = 8 THEN pf.ly_next_week_net_sales
           END) week5,
           SUM(CASE WHEN pf.week_number = 5 AND dummy.col1 = 1 THEN pf.lns_ptd
                    WHEN pf.week_number = 5 AND dummy.col1 = 2 THEN pf.aws_ptd
                    WHEN pf.week_number = 5 AND dummy.col1 = 3 THEN pf.ljsf_ptd
                    WHEN pf.week_number = 5 AND dummy.col1 = 4 THEN pf.tbs_ptd
                    WHEN pf.week_number = 5 AND dummy.col1 = 5 THEN pf.net_ptd
                    WHEN pf.week_number = 5 AND dummy.col1 = 6 THEN pf.ly_net_ptd
                    WHEN pf.week_number = 5 AND dummy.col1 = 7 THEN pf.net_ptd - pf.ly_net_ptd
                    WHEN pf.week_number = 5 AND dummy.col1 = 8 THEN pf.ly_nwns_ptd
           END) period_to_date,
           SUM(CASE WHEN pf.week_number = 5 AND dummy.col1 = 1 THEN pf.lns_ytd
                    WHEN pf.week_number = 5 AND dummy.col1 = 2 THEN pf.aws_ytd
                    WHEN pf.week_number = 5 AND dummy.col1 = 3 THEN pf.ljsf_ytd
                    WHEN pf.week_number = 5 AND dummy.col1 = 4 THEN pf.tbs_ytd
                    WHEN pf.week_number = 5 AND dummy.col1 = 5 THEN pf.net_ytd
                    WHEN pf.week_number = 5 AND dummy.col1 = 6 THEN pf.ly_net_ytd
                    WHEN pf.week_number = 5 AND dummy.col1 = 7 THEN pf.net_ytd - pf.ly_net_ytd
                    WHEN pf.week_number = 5 AND dummy.col1 = 8 THEN pf.full_net_ytd
           END) year_to_date,
           stores.companyname,
           stores.districtname,
           stores.storename,
           stores.storenbr 
    FROM   pivoted_foods pf
           LEFT OUTER JOIN storedetails stores ON stores.storeid = pf.storeid,
           dummy
    group by dummy.col1,
             DECODE(dummy.col1, 1, 'Net - Landau',
                              2, 'Net - AW',
                              3, 'Net - LJS',
                              4, 'Net - TB',
                              5, 'Total Net',
                              6, 'Last Year Sales',
                              7, 'Increase',
                              8, 'Last Year Next Week'),
             rollup((pf.storeid,
             stores.companyname,
             stores.districtname,
             stores.storename,
             stores.storenbr))
    order by pf.storeid, dummy.col1;(replace all :v_num_weeks, :v_bop and :v_bop_ly references with your variables)

  • JDBC Message size restriction

    Hi All,
    Has any one used JDBC sender adapter message size restrction parameters which are specified in note 1253826?
    I have configured below 3 parameters as per note but its not working.
    msgLimit = true
    maxMsgSize = 10240
    maxRowSize = 2
    As per my configuration, I see 1 record size is 2 KB hence maxRowSize = 2. I am allowing max 10MB load to come in so maxMsgSize value as 10240. but even for 1 record I am getting error as ERROR_MAX_MSG_SIZE_REACHED which is not expected.
    Please let me know if some one has used above parameters successfully.
    Thanks in advance.
    Regards
    Sushil

    Hi Sushil
    Use this concept.
    Its very simple if you know the SQL or oracle.
    Whatever is you database just apply TOP query in your select query and update query in your sender JDBC adapter.
    If you dont know the query just search in google.
    What TOP Query do:
    for example ( SQL Server ) i have to pic only 10000 records from the 50000 records present in table.
    Here i will apply ---
    Select TOP 10000 fieldName1, fieldName2 from TableName where clause...
    Update TOP(10000) TableName set fieldName1='1' where clause...
    Use this query and your problem will be solved.
    Please dont forget to make it Transaction Level Isolation = serializable (under Advanced --> Additional Parameters in your sender Communication channel)
    Hope so it will solve your problem.
    Regards
    Dheeraj Kumar

  • PIVOT Function in isqlPlus ???  HELP please!

    I need to Pivot a column of Numeric data in a table.
    The data is as follows: (I generate this table in a VIEW):
    COL1 COL2 COL3
    jdoe green -1
    jdoe blue -1
    jdoe yellow 0
    jdoe red 0
    jdoe orange -1
    asmith blue 0
    asmith green -1
    asmith gold 0
    asmith yellow -1
    asmith red -1
    asmith orange 0
    I produce this table of data from a VIEW select statement.
    I am writing a second VIEW select as a subquery to this top query. I want the second or subquery VIEW select to produce a PIVOT of the third column that will produce the following for me:
    COL1 COL2 COL3 COL4
    jdoe 5 3 2
    asmith 6 3 3
    ...the end result being one row for each username with a breakout of total count of -1's and total count of 0's, and of course a grand total in Col2.
    I cannot find any sensible documentation in the miles and miles of documentation within Oracle's library. Can anyone help me please?

    select col1
    , count(*) col2
    , sum(decode(col3,-1,1,0)) col3
    , sum(decode(col3,0,1,0)) col4
    from your_table
    group by col1

Maybe you are looking for