How to use variables in the report?

Hello all,.
I'm new to PlSql. Please bare with me.

I have a report that runs on SSRS.
Here is what I need it to do:

When the report is run:
1st of the month: it pulls the data from the previous months.
16th of the month: from the 1st of the current month to 15.

I am trying to use a case statement to find the right date and then use this value to ReportDate.
ReportDate is a column in the database.

-Find the 1st of the month
SELECT
CASE
WHEN SYSDATE > last_day (add_months (SYSDATE-1))
AND SYSDATE < last_day (add_months (SYSDATE,-1)) + 2
THEN
ReportDate = last_day (add_months (SYSDATE-2))

ON THE OTHER
SYSDATE
END ReportStartDate,

With the help of 10G.
Again, I'm pretty new to this, so go easy. Let me know if I can provide any other details.

Hello

Welcome to the forum!

1009545 wrote:
Hello all,.
I'm new to PlSql. Please bare with me.

Certainly not! Isn't this kind of a site!
Did you mean "Please * bear * with me?"

I have a report that runs on SSRS.
Here is what I need it to do:

When the report is run:
1st of the month: it pulls the data from the previous months.
16th of the month: from the 1st of the current month to 15.

What happens if it is running on another day of the month?
The query below uses leans on the previous month when it circulates at any time from 1, in the 15th day of the month, inclusively and leans on the 1st to the 15th of the current month when run 16 or later.

I am trying to use a case statement to find the right date & then use this value to ReportDate.
ReportDate is a column in the database.

-Find the 1st of the month
SELECT
CASE
WHEN SYSDATE > last_day (add_months (SYSDATE-1))

ADD_MONTHS (SYSDATE-1) will always be some time this month, then
LAST_DAY (ADD_MONTHS (SYSDATE-1) will also be the previous month, but)
SYSDATE is always in the current month,
SYSDATE > ADD_MONTHS (SYSDATE-1) will always have the value TRUE.

AND SYSDATE< last_day(add_months(sysdate,="">
THEN
ReportDate = last_day (add_months (SYSDATE-2))

It's 2 months in the past. Are you ever interested in this old stuff? Areen can't you always interested in 1 months ago, or the current month?

ON THE OTHER
SYSDATE
END ReportStartDate,

With the help of 10G.
Again, I'm pretty new to this, so go easy. Let me know if I can provide any other details.

Whenever you have a problem, post CREATE TABLE and INSERT statements for some examples of data and outcomes from these data.
See the FAQ forum {message identifier: = 9360002} it only takes a few minutes to read and can really help you get the most out of this forum.

I think you want something like this:

WITH     period_of_interest     AS
(
     SELECT     CASE
              WHEN  TO_CHAR (SYSDATE, 'DD') < '16'
                                       -- should be '16' above.  See note
              THEN  TRUNC ( ADD_MONTHS (SYSATE, -1), 'MONTH')
              ELSE  TRUNC (             SYSDATE    , 'MONTH')
          END     AS period_start
     ,     CASE
              WHEN  TO_CHAR (SYSDATE, 'DD') < '16'
              THEN  TRUNC (SYSDATE, 'MONTH')
              ELSE  TRUNC (SYSDATE, 'MONTH') + 16
          END     AS period_end
     FROM    dual
)
SELECT     ...
FROM     table_x              x
JOIN     period_of_interest  p  ON  x.transaction_date >= p.period_start
                      AND x.transaction_date <  p.period_end
;

Period_end is a somewhat misleading name for the column; It's actually the first DATE after the end of the period; That's why I used < (and not < =) when compared to the x.transaction_date.

I'm not sure what ReportDate is in your description. This is an example of timid, you must validate CREATE TABLE and INSERT statements for some examples of data. It could be that ReportDate is just what I called transaction_date above.

Published by: Frank Kulash on June 3, 2013 16:55
This site is falling out my code. It seens to think the in the first

WHEN TO_CHAR (SYSDATE, 'DD') < '16'

indicates a kind of markup and will not display the '16', even if I put it on a separate on its own line.

Published by: Frank Kulash on June 3, 2013 17:09
Used & lt; to correct the estrangement, after sentries below.

Tags: Database

Similar Questions

  • How to use paper in the latest version of Windows Live Mail?

    How to use paper in the latest version of Windows Live Mail?

    Version 2011

    Short answer: the stationery support has been removed from Windows Live Mail with the upgrade of v.2009 v.2011 back in 2010.

    Long answer: there are two solutions of workaround that you can try.

    • If you have a stationery .htm file, open it in Internet Explorer, and then select file > Send > Page by email (Alt - F E P). Save the message as a result as a .eml file and use it as a model for messages.
    • You can get in shape, for example a background color, to a HTML signature, then apply this signature to an e-mail message. Here's the one I use when sending pictures:


      Hello!

      Love
      Noel


      Here is the result:

  • JavaFX how to use WebView load the local HTML page?

    JavaFX how to use WebView load the local HTML page?

    If the HTML code of the files in the class path, which is in the package, the load using one of the following ways:

    String url = Main.class.getResource("/html/index.html").toExternalForm();
    engine.load(url);
    

    The above methods can only load files outside the class path!

  • How to use PS to judge the existence of a file in the directory specified and how to use PS to the directory specified for create to create the file? (javascript)

    1, how to use PS to judge of the existence of a file in the specified directory? (using javascript)

    2, how to use PS to the directory specified for create to create the folder? (using javascript)


    Thank you!

    If (Folder(/*_insert_the_path_here_*/).exists == false) {Folder(/*_insert_the_path_here_*/).create()}

  • How to use photoshop with the same account on more than one laptop?

    How to use photoshop with the same account on more than one laptop?

    a single user license entitles you to two facilities simultaneous/activations.  so, what's the problem?

  • Using variables in the queries and dashboards

    Hi Freinz,

    I am using a prompt and dashboard based on the selection in the guests shud of data filled.

    I used the query variable line dashboard option and creates reference static variables of the administration.

    I created the 'green' variable and in the applications for the "VERTICAL" column, I put the variable as being of 'green '.
    It is the same value as I gave in the prompt variable set dashboard-> variable query.

    Guyz pls help me...

    Pls let me know the steps to follow.

    How shud I? the values in the row of dashboard applications /

    Thank you
    Veena

    In the report, create a filter of coming and going VERTICAL. In the filter creation, click on Add - Variable - presentation, now in the Expr variable name of the variable, the default value indicates no value for this PORTRAIT.

    Now, put your prompt and the dashboard report, test.

  • How to use variable Substitution Essbase in ODI

    Hello

    Can someone help me please how to use void var Essbase in ODI?
    I created an interface to load data from text to planning. In the mapping, to the Point of view, I gave the necessary dimensions which is "years". In Essbase, we set a variable called CurrYr which
    We want to use in the view. So, I added a line like this in the map

    'Work', 'Budget', 'CC1', '#sYearValue '. The sYearValue is used to extract the void var Essbase before loading the planning data. I have followed the blog for void var post below (John has been very kind in showing many examples of ODI, link below is one of them).

    [http://john-goodwin.blogspot.com/2009/11/odi-series-planning-11113-enhancements.html]

    Whenever I run the Interface, it fails with the error "ODI-17506: Variable has no value: XXXXX.sYearValue.

    Thanks in advance!

    PM

    This line should print the values in the agent log, see log

    System.out.println ("current year =" + sYearValue + "current period =" + sPerValue);

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • How to put links to the reports by e-mail?

    We use ibots to schedule reports, then distribute them by e-mail.
    Is there some way, we can send the links instead of reports.
    The link that we see in the browser for a specific report should be sent by electronic mail instead of report.
    Users should be able to click on the link and then provide the credentials to connect. Then only, they should be able to see the reports.
    Can anyone suggest a way to do this.

    Thank you
    Swetha

    OK, how about a total different approach?

    You said that you needed your reports to run at a time specific (you gave the example of 09:00) with the data at that time. Links must be to the 'already-run' reports, not having only not reports to run when you click the links. Yes?

    If so, then think about this. Use your iBots to run at the scheduled time and file reports on a file server. How? Read this:

    http://oraclebizint.WordPress.com/2007/12/17/Oracle-BI-EE-101332-calling-Java-scripts-and-Java-classes-from-ibots/

    Now you can use your email application to send regular emails (when reports are run) to have users access to reports on the server at a given time. You can create a javascript script for each different place depending on who needs to see that report. In this way, the when users connect to the site, they see only the reports that they are supposed to see.

  • How to use and control the tabs?

    Sorry for such a general question, but I use Firefox with older versions of Mac OS x for years and have just been struck by this brand new and I have no idea on your tabs, "new tab page" etc. Can you just send me some documents so I can understand what they are and how to use them?

    All I see on my headers Ff are all sorts of legs that have no relevance to me, like 'how to stop Firefox from... '. "(twice), a few other symbols Ff and other"tabs"I don't know everything." All the do is filling up a bar line.

    Thank you-

    You are welcome.

    If you have any other questions feel free to ask them.

  • How to use notes during the writing of my book with pages?

    How are used to write a book with pages of notes?

    You need the Apple EndNote plug-in for Pages v2.0and the EndNote 7.3.4 application (or later version) installed for compatibility El Capitan. With the plug-in installed and EndNote works, then you start Pages v5.6.1 and the Insert menu: reference EndNote is available for use. Launch Pages v5.6.1 prior to 7.3.4 EndNote and endnote reference entry in the Insert menu is not active.

  • How to use PersistentBitmap in the version 5.0 or any other method?

    I am completely unaware of an example of use of PersistentBitmap and am also not sure if it can be used in 5.0 but anyway, I extract the code next, I received, could someone advise me on how to use it?

    I have several images I want to stay put on the BB, even after a hard reboot. Links or advice is welcome! Thank you

    {classPersistableBitmapimplementsPersistable}
    int width;
    int height;
    int [] argbData;

    publicPersistableBitmap (Bitmap image) {}
    width = image.getWidth ();
    height = image.getHeight ();
    argbData newint = [width * height];
    image.getARGB (argbData, width, 0, 0, 0, width, height);
    }

    publicBitmap getBitmapImage() {}
    Bitmap image = newBitmap (width, height);
    image.setARGB (argbData, width, 0, 0, 0, width, height);
    return image;
    }

    The link below points to the documentation on the use of persistent store.  Take a look and let me know if you get stuck.

    https://bdsc.webapps.BlackBerry.com/Java/documentation/ww_java_datastorage/PersistentStore_intro_198...

  • How to pass Variables from the Source (SQL) to tab target (JavaBin Shell) in ODI knowledge Modules

    Hi all

    My name is Alessandro and I am new to the community.

    I have a problem with the KM stage custom when I try to pass the variable from the source to the target.

    The ODI version tha I use is the 11.1.1.5.0.

    I created a stage KM following the instructions of the metalink document (Doc ID 728636.1).

    But when I insert the value of the variable in a test table, the value in a table is the name of the variable.

    Where I'm wrong?

    I am doing thi.

    (1) create a step in my goal of shell sql source and javabin KM. In the source tab I get the value of a query, and the name "LAST_UPDATE" column.

    In the target tab, I attribute to the variabile jv_last_update the value of the variable #LAST_UPDATE, with the same name in the selection column.

    source_tab.jpgtarget_tab.jpg

    (2) I created a second stage where I insert into a table of the value of the variable jv_last_update (to debug the value of the variable):

    insert_step.jpg

    (3) when I try to see what I have in the table, the value of any line is the name of the variable "#LAST_UPDATE"; ".

    result_table.jpg

    Thanks in advance


    Alessandro

    Hi Alessandro,.

    Interesting... I have not read the Oracle document you sent yet, but one thing I can guarantee you, is that it doesn't. If Oracle says that it should work, maybe it's a bug, or maybe he has changed on new versions of ODI. I am also on ODI 11.1.1.5 and I tried many different ways to pass SQL results to variables of java with all sorts of different labels, but none of them worked for me as well. But I managed to use it in a different way, so please see below if it matches your needs:

    We are just one step. The second is just to show that it worked:

    In the first step, on the source tab, select Oracle and point to the logical schema that you want to run the query:

    On the target, note the following Java BeanShell code with the SQL that you want to run:

    Now your variable must have the correct value of your SQL. To test it, I just write a comment 'Raise' to Jython in the second step:

    The result is 'X' as expected:

    It will be useful.

    Thank you!

  • How REGEXP_REPLACE used to replace the part of the string?

    Hello

    How can I replace the portion of string as follows, I want to replace the space as by ' - '.

    SELECT
    REGEXP_REPLACE (superior ("' Laura bought stuff from 2000 USD on 12 September 2012 to KL and kl left on September 20, 2012"),)
    ' [0-9] {1,2} [^ 0-9](JAN|) FEB | MAR | APR | JUN | JUL | AUG | MS | OCT | NOV | DEC) [^ 0-9] [0-9] {4}',
    (','-') "REGEXP_REPLACE.
    FROM DUAL;

    the output will be like this

    Laura bought of the stuff of 2000 USD on 12-Sep-2012 of KL and kl left on 20-Sep-2012

    concerning

    Something like that?

    SELECT
    REGEXP_REPLACE('Daivd bought stuff by 2000 USD on 12 Sep 2012 from KL and left kl on 20 Sep 2012',
    '([0-9]{1,2}) (JAN|FEB|MAR|APR|JUN|JUL|AUG|SEP|OCT|NOV|DEC) ([0-9]{4})',
    '\1-\2-\3',1,0,'i') "REGEXP_REPLACE"
    FROM DUAL;
    

    Explanation:

    You group the parts of the date de-construct with (additional).
    You can use expressions, backreference \1 \2 \3 and add '-' between \1-\2-\3 signs.

    You should not user upper ('...') in the first parameter. If you cannot recover the original state of the letters.
    If you want to case-insensitive matching you should use 'I' in the last parameter of regexp_replace.

    http://docs.Oracle.com/CD/B19306_01/server.102/b14200/functions130.htm

    Published by: hm on 25.09.2012 00:38

  • Using variables in the command 'get-stat"powercli

    Hello

    I try to collect data via powershell and vsphere powercli I would like to pass several stat ID, both using variable that contains my ID stat list.

    (1) when I do this...

    Get-stat - entity (get-vmhost $host_id) - mem.active.average, sys.resourcecpuusage.average real-time stat - maxsamples 1

    ... It works very well

    (2) when I do this...

    $list = "mem.active.average".

    Get-stat - entity (get-vmhost $host_id) - stat $list - realtime - maxsamples 1

    ... It works fine, I can pass variables and so ID stat, one at a time.

    (3) when I do this...

    $list = 'mem.active.average, sys.resourcecpuusage.average '.

    Get-stat - entity (get-vmhost $host_id) - stat $list - realtime - maxsamples 1

    ... It does not work. PowerCLI returns... There is no entity the metric counter 'mem.active.average, sys.resourcecpuusage.average'...

    I do not understand where the problem is during the passage of variables, an idea?

    This should be

    $list = "mem.active.average","sys.resourcecpuusage.average"
    get-stat -entity(get-vmhost $host_id) -stat $list -realtime -maxsamples 1
    

    Must be an array of strings.

  • How to use setFireActionForSubmit with the settings and capture the parameter

    Hello

    Can someone explain how to use setFireActionForSubmit.

    I extend the ShoppingCartPG controller. In the extended controller processRequest method I am adding a button to the table and implementation of the setFireActionForSubmit, so when the button is pressed it triggers the setFireActionForSubmit event.
    I need to pass the RequisitionLineId as a parameter which is present in the t associated with the ShoppingCartPG.

    I used the following code in the processRequest
    =================================
    ' public void processRequest (OAPageContext paramOAPageContext, OAWebBean paramOAWebBean)
    {
    super.processRequest (paramOAPageContext, paramOAWebBean);
    OATableBean otbRN = (OATableBean) paramOAWebBean.findIndexedChildRecursive ("ItemTableRN");
    OASB OASubmitButtonBean = (OASubmitButtonBean) paramOAPageContext.getWebBeanFactory () .createWebBean (paramOAPageContext, "BUTTON_SUBMIT");

    oasb.setID ("addnInfo");
    oasb.setUINodeName ("addnInfo");
    oasb.setText ("additional information");

    String pageName = paramOAPageContext.getRootRegionCode ();
    Hashtable params = new Hashtable (1);
    params.put ("param1", pageName);

    Hashtable paramsWithBinds = new Hashtable (1);
    paramsWithBinds.put ("param2", new OADataBoundValueFireActionURL (OASB, "${oa.encrypt.current.RequisitionLineId}"));
    oasb.setFireActionForSubmit ("addnInfoEvent", params, paramsWithBinds, false, false);

    otbRN.addIndexedChild (oasb);
    }
    =================================

    And I capture the event "addnInfoEvent" in processFormRequest method and trying to capture the RequisitionLineId I the past as a parameter.
    This is the code that I used in processFormRequest.
    =================================
    ' Public Sub processFormRequest (OAPageContext paramOAPageContext, OAWebBean paramOAWebBean)
    {
    super.processFormRequest (paramOAPageContext, paramOAWebBean);
    OAApplicationModule localOAApplicationModule = (paramOAWebBean) paramOAPageContext.getApplicationModule;

    String strEvent = paramOAPageContext.getParameter (EVENT_PARAM);

    If ("addnInfoEvent".equals (strEvent))
    {
    Number format = 0;
    try {}
    Format = new Integer (ClientUtil.getDecryptedParameter (paramOAPageContext, "param2"));
    }
    catch (System.Exception e) {e.printStackTrace () ;}

    String outmsg = "line ID:" + size + ":" + strEvent;
    throw new OAException (outmsg, OAException.INFORMATION);
    }
    }
    =================================

    But I'm not able to capture the RequisitionLineId I sent as a parameter.
    Can someone let me know what I am doing wrong.

    Hello

    Because your table is not a tip so table using a submit button approach will not work because it won't give you rank of reference and you will not be able to enter the id of the corresponding command line, instead you use an icon of the image, which can be created through customization. Let me know if you need help in the code.

    Thank you
    Pratap

Maybe you are looking for

  • We had to get a new computer and I want to copy bookmarks. Where were they stored?

    Our old computer, desktop with Windows XP, wouldn't start, so we bought a new one (Windows 7). Extraction of data from the hard drive of the old computer. Is it possible that I can get the Firefox bookmarks? All information I found had to do with boo

  • Resolution of a system of nonlinear equations

    Hey guys,.Currently, I am trying to solve a set of nonlinear equations in LabView with the help of MathScript and MATLAB code. I am trying to create a code of work for hours, but I have not yet reached this goal. System of equations: x ^ 2 + y ^ 2 +

  • HP 6500 a Plus: HP 6500 has more won't copy

    This old all-in-one device has served reliably for many years until today.  It prints and scans but won't copy glass.  I unplugged the wall for 30 seconds and then tried a second time with the same results.  Help!

  • P0rn sites incorporated in I.E. 6.0 - need help to remove

    Thanks to an email from bad, I have now three p0rn sites incorporated into my program I.E. 6.0. Is there a way to "désincorporer" them, or should I just uninstall I.E. and reinstall it. If I need to unstall it, how should I do that? It is not in Add/

  • DELL INSPIRON 5548: PROBLEMS OF DRIVER WEBCAM

    Hello I recently bought a 5th generation Dell portable computer 5548 with recognition software preinstalled facial quick access. After a month of using the facial recognition software, it took a license purchase. Because I wasn't ready to continue wi