Creating an Hour field in an SQL Query CUIC v10.0

I am trying to create a report that shows the calls offered etc by Hour, instead of by half hour or 15 minutes which comes with the usual DateTime (interval) query.
I am using DATEPART (Hour, DateTime) As Hour  and whilst this is giving me the hour number in the new column, I an showing 2 rows per hour as per the half hour interval.
I have included it in the Group By and this makes no difference, Whilst I can group them by hour and that would in effect solve the issue, I then loos the Date Field!
Ideally what I would like to see in 1 column is
Call Type 1    4/2/15 10:00 AM
                      4/2/15 11:00 AM
                      4/2/25 12:00 AM
etc.....
Instead what I have is
Call Type 1    4/2/15 10:00 AM         10
                      4/2/15 10:30 AM         10
                      4/2/25 11:00 AM         11
                      4/2/25 11:30AM          11
etc...
If there is anyone out there that can help I would be most grateful
Thanks Sarah

Sarah,
You will need to make sure you remove "DateTime" from your GROUP BY clause, and from the SELECT statement.
Instead of using DATEPART, I would use something like:
DateTimeHour = DATEADD(h,DATEDIFF(h,0,DateTime),0)
The above will give you a full DateTime value, rounded down to the nearest hour. Don't forget to include it in the GROUP BY (and probably SORT BY).
You can add "DateTime" back as Filter Field in CUIC after you do the initial Create Fields step (look on the Fields page). Filtering on DateTime instead of DATEADD(h,DATEDIFF(h,0,DateTime),0) should make for a more efficient SQL query.
-Jameson

Similar Messages

  • Use of FIELD in Attribute SQL Query

    Hi folks,
    Back in 7.1 you could use %FIELD.[attributename]% in a sql query defining an identity store attribute's values.
    Does anyone know if this functionality was lost in 7.2?  Can't seem to get it to work.
    Thanks,
    Matt

    Hi Moritz,
    did you consider that note:
    Note: Both
    fields must be
    defined as "Single value" with presentation type "Single select"?
    It does not work as soon as you use other storage or presentation types.
    Regards
    Norman

  • Creating a ad-hoc calculation using sql query

    Hi All,
    I want to know if its possible some way to create a ad-hoc sql query inside a workbook so as to create a calculation using that sql.
    I have a folder which gives me balance for any period. My requirement is to display current period balance along with prior years closing balance in same record for each code combination. I dont want to modify folder definition.
    Thanks for your inputs.
    Vishal.

    You could try creating a custom function for this purpose. You would need to register the function in the End User Layer and then you can call the function from your report.

  • Inserting field text into sql query and comparing values to another table

    I have an issue in Visual Web Developer 2010 that I need help with.
    The code below is a Gridview Sql query where I'm extracting PART_NUMBER from various tables.  I would like to add the table name in a separate field named Table.  The end result should appear as follows:
    PART_NUMBER     Table
    010-0075-06       Resistors (or Capacitors, etc.)
    Sql query:
    SELECT     PART_NUMBER
    FROM         Capacitors
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         Connectors
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         Diodes
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         ICs
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         Inductors
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         Misc
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         Relays
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         Resistors
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         Switches
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         Transformers
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         Transistors
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    UNION
    SELECT     PART_NUMBER
    FROM         [Crystals and Oscillators]
    EXCEPT
    SELECT     PART_NUMBER
    FROM         [CIS Manufacturer Parts]
    ORDER BY PART_NUMBER
    I have a separate table (CIS Manufacturer Parts) that contains manufacturer data for the above parts.  Multiple manufacturer rows can exist.  The connection between tables in the PART_NUMBER field.  What I would like to do is make this query
    add the table name to the gridview output listing only parts without manufacturer data and the table they can be found in.
    This is a lot for a newbie so I will appreciate any help, thanks!

    Hello Bulldog248,
    Thank you for your post.
    Your issue is out of support range of VS General Question forum which mainly discusses the usage issue of Visual Studio IDE such as
    WPF & SL designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System
    and Visual Studio Editor.
    I am moving your question to the moderator forum ("Where is the forum for..?"). The owner of the forum will direct you to a right forum.
    Best regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • What Indexes should be created for improve performance of the sql query

    Hello Admins
    One of my user is facing slow performance issue while running the below query. Can someone, please guide me for the same. I want to know, what indexes should be created to improve the performance of this query. Also what else can be done to achieve the same.
    SQL Query:-
    SELECT UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.PO_NUMBER))),
    CGSBI_SHIP_DIST_S_EXTRACT.PO_LINE_NUMBER,
    CGSBI_SHIP_DIST_S_EXTRACT.PO_SHIPMENT_NUMBER,
    CGSBI_SHIP_DIST_S_EXTRACT.PO_LINE_SHIP_DIST_NUMBER,
    CGSBI_SHIP_DIST_S_EXTRACT.DISTRIBUTION_DATE,
    UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.PO_LINE_SHIP_DIST_LINE_ID))),
    UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.PROJECT_ID))),
    UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.ACCOUNT_DISTRIBUTION_CODE))),
    UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.ORACLE_ACCOUNT_NUMBER))),
    UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.COMPONENT_CODE))),
    UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.TRANSACTION_CURRENCY_CODE))),
    CGSBI_SHIP_DIST_S_EXTRACT.ORDER_QUANTITY, UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.ORDER_UOM))),
    CGSBI_SHIP_DIST_S_EXTRACT.UNIT_PRICE_TRX_CURRENCY,
    UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.EXPENSE_TYPE_INDICATOR))),
    CGSBI_SHIP_DIST_S_EXTRACT.SOR_ID,
    UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.PO_LINE_ITEM_CODE))),
    UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.PO_LINE_ITEM_DESC))),
    CGSBI_SHIP_DIST_S_EXTRACT.PO_LINE_ITEM_LEAD_TIME,
    UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.UNSPSC_CODE))),
    UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.BUYER_ID))),
    UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.REQUESTOR_ID))),
    UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.APPROVER_ID))),
    UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.SUPPLIER_SITE_ID))),
    UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.SUPPLIER_GSL_NUMBER))),
    UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.SHIP_TO_LOCATION_CODE))),
    UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.TASK_ID))),
    (LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.PO_RELEASE_ID)))
    FROM
    CGSBI_SHIP_DIST_S_EXTRACT
    WHERE PO_NUMBER IS NOT NULL;
    I generated the explain plan for this query and found the following:-
    Explain Plan:-
    SQL> explain plan for SELECT UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.PO_NUMBER))),
    2 CGSBI_SHIP_DIST_S_EXTRACT.PO_LINE_NUMBER,
    3 CGSBI_SHIP_DIST_S_EXTRACT.PO_SHIPMENT_NUMBER,
    4 CGSBI_SHIP_DIST_S_EXTRACT.PO_LINE_SHIP_DIST_NUMBER,
    5 CGSBI_SHIP_DIST_S_EXTRACT.DISTRIBUTION_DATE,
    6 UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.PO_LINE_SHIP_DIST_LINE_ID))),
    7 UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.PROJECT_ID))),
    8 UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.ACCOUNT_DISTRIBUTION_CODE))),
    9 UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.ORACLE_ACCOUNT_NUMBER))),
    10 UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.COMPONENT_CODE))),
    11 UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.TRANSACTION_CURRENCY_CODE))),
    12 CGSBI_SHIP_DIST_S_EXTRACT.ORDER_QUANTITY, UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.ORDER_UOM))),
    13 CGSBI_SHIP_DIST_S_EXTRACT.UNIT_PRICE_TRX_CURRENCY,
    14 UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.EXPENSE_TYPE_INDICATOR))),
    15 CGSBI_SHIP_DIST_S_EXTRACT.SOR_ID,
    16 UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.PO_LINE_ITEM_CODE))),
    17 UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.PO_LINE_ITEM_DESC))),
    18 CGSBI_SHIP_DIST_S_EXTRACT.PO_LINE_ITEM_LEAD_TIME,
    19 UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.UNSPSC_CODE))),
    20 UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.BUYER_ID))),
    21 UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.REQUESTOR_ID))),
    22 UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.APPROVER_ID))),
    23 UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.SUPPLIER_SITE_ID))),
    24 UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.SUPPLIER_GSL_NUMBER))),
    25 UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.SHIP_TO_LOCATION_CODE))),
    26 UPPER(LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.TASK_ID))),
    27 (LTRIM(RTRIM(CGSBI_SHIP_DIST_S_EXTRACT.PO_RELEASE_ID)))
    28 FROM
    29 CGSBI_SHIP_DIST_S_EXTRACT
    30 WHERE PO_NUMBER IS NOT NULL;
    Explained.
    SQL>
    SQL>
    SQL> SELECT * FROM TABLE(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3891180274
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 77647 | 39M| 2006 (1)| 00:00:25 |
    |* 1 | TABLE ACCESS FULL| CGSBI_SHIP_DIST_S_EXTRACT | 77647 | 39M| 2006 (1)| 00:00:25 |
    Predicate Information (identified by operation id):
    1 - filter("PO_NUMBER" IS NOT NULL)
    13 rows selected.
    SQL>
    SQL>
    Kindly suggest on this...
    Thanks & Regards
    -Naveen Gangil
    Oracle DBA

    Rafi is correct. Since po_number is the filter column, the only chance you have for using an index to access the table is on that column. However, if there are few (or none) rows with null po_number, you will always have FTS. Does the table have a PK ( which probably consists of at least po_number, line_number )? If that is the case po_number could never be null and in which case you are dumping the whole table and no indexing scheme is going to improve the queri's performance. You might, repeat might, see performance improvement if you cleanse the data in the table ( to eliminate the need for UPPER(LTRIM)RTRIM())) ) before querying it so the the data does not have to be massaged before returning it.

  • Sum fields in a sql query

    Hi,
    somebody knows how to sum two columns of a table as a result of an abap sql query. I know that is possible to do it in a native sql like
    select f.seatmax max, f.seatfree free, f.seatmax - f.seatfree seatoccu from flights
    Tks
    Roberto Falk

    Hi Roberto , 
      Here is a sample code which does some thing similar
    Data : v_LABST type LABST ,
           v_umlme type umlme.
    start-of-selection.
           select sum( labst ) sum( umlme )
             into (v_labst , v_umlme)
             from mard.
    write:/ v_labst , v_umlme.
    Regards
    Arun

  • Sorting of Date field in the SQL Query useing ORDER BY

    Hi
    I am facing a problem when I am getting the results of a query from the ORacle 8i database using jdbc connection.
    The query is having a date field and I have to sort the query results using ORDER By for the Date field. The query is giving exact results in the SQL PLus interface.
    When I am getting this results in the GUI where servlets are being used an Exception is coming as not supported RefreshRow method.
    If anyone has faced this problem and have got the solutions please let me know.
    thanks
    sulfy

    That doesn't sound at all like an SQL problem.
    More like you trying to do updates on the resultset which is not allowed ...
    send a some code (not to much pls :) and we'll be
    able to help more
    cu
    Spieler

  • How to combine a raw xml file stored in a table field withe other sql query in . xsq

    I created .xsql file like this:
    <xsql:query>
    select xml_file from my_table
    </xsql:query>
    xml_file is field in my_table,it stores raw xml files.
    the xml file in the result is in text format, not in xml format,how to convert the file into xml format in the result

    See the "document" demo that ships with the XSQL servlet for an example of how to do this.
    It lives in the ./demo/document subdirectory.

  • Creating tabular form using SQL query

    Hi,
    I need to create a tabular form using an SQL query so that multiple rows of a table are displayed on screen and are editable to the user.
    I have created this sort of form before using the Tabular Form wizard however for this form I need to enter SQL to produce it.
    The steps I take are:
    1. Create Page
    2. Page with Component
    3. Form
    4. Fow on a SQL query
    5. For the query I have: 'select * from depot_master_customer'
    However when I view the page, it just displays one blank field with the title '*' !!
    I am doing something completely wrong here? It seems like it should be a simple thing to do.
    Any help appreciated, this one is driving me mad.
    Thanks
    Simon

    Simon,
    You will need to manually create the tabular form and DML process. This is covered in detail in the How To document shown below:
    http://www.oracle.com/technology/products/database/htmldb/howtos/tabular_form.html
    Have you tried this yet?
    Good luck!
    Emilio.

  • Creating a  Calendar from SQL Query

    Hi --
    I'm trying to create a calendar based on a sql query, but I need to be able to select the unique id in order to pass it to a page that will display the event details. It looks like I'm not able to select a "hidden" value in my sql query, but am limited to those columns defined by Oracle. Any feedback would be greatly appreciated.
    Thanks,
    Christine

    Hi,
    I think the VO->AM->Data Control is the proper and simple way.
    Executing sql query must have a database connection, handling database connection is the main purpose of AM.
    Suggesting AM style data control.
    Todd

  • How to replace a dates on a SQL query on Visual Studio (and get the query to work in there in the first place)?

    Morning all,
    I've just been assigned a report-related project but I have not created much of anything in C# or .Net before!
    I was wondering if someone could help me get started. Here are the specifications:
    Basically, I am to create an automated report application. I have the query and I will include it further down
    in this post. The page is to have a couple blanks to specify the Start Date and End Date and replace those dates in the query, and generate the report. What I need some help on is how to make the SQL query work in the application which I will connect to the
    intended database to generate the report (basic I know, but I'm new at this) on Visual Studio 2010. I also need some help on programming the Start Date blank and End Date blank so that what the user types in for those blanks will replace the date fields in
    the SQL query, then generate the report with the new dates. 
    I appreciate the help!
    The SQL query and what the dates are replacing:
    select 
    PTH.INST_ID ,
    PTH.EMPLOYEE_ID,
    DBH.HR_DEDUCTION_AND_BENEFITS_CODE,
    replace(DB.DESCRIPTION,',',''),
    DB.WITHHOLDING_LIABILITY_ACCOUNT_MASK,
    DBH.HR_DEDUCTION_AND_BENEFITS_ID,
    DBH.CHECK_DATE,
    DBH.CHECK_NO,
    DBH.FIN_INST_ACCT_ID,
    replace(replace (DBH.COMMENT,CHAR(10),' '),CHAR(13),' '),
    DBH.HR_DEDUCTION_AND_BENEFIT_CYCLE_CODE,
    DBH.LENGTH,
    DBH.EMPLOYEE_COMPUTED_AMOUNT,
    DBH.EMPLOYEE_BANK_ROUTING_NUMBER,
    DBH.EMPLOYEE_ACCOUNT_TYPE,
    DBH.EMPLOYEE_ACCOUNT_NUMBER,
    DBH.EMPLOYER_COMPUTED_AMOUNT,
    DBH.EMPLOYEE_GROSS_AMOUNT,
    DBH.EMPLOYER_GROSS_AMOUNT,
    DBH.PAYROLL_EXCLUDE,
    PTH.VOID_DATE,
    PTH.BATCH_QUEUE_ID,
    B.BATCH_CODE,
    BQ.FY,
    BQ.END_DATE,
    BQ.COMMENTS,
    BQ.BATCH_CRITERIA_USED,
    BP.COLUMN_VALUE,
    PTH.REPLACEMENT,
    P.LAST_NAME,
    P.FIRST_NAME,
    P.MIDDLE_NAME
    from PY_EMPLOYEE_TAX_HISTORY PTH
    INNER JOIN PERSON_EMPLOYEE PE ON
    PE.INST_ID=PTH.INST_ID AND
    PE.EMPLOYEE_ID=PTH.EMPLOYEE_ID
    INNER JOIN PERSON P ON
    PE.INST_ID=P.INST_ID AND
    PE.PERSON_ID=P.PERSON_ID
    LEFT JOIN HR_EMPLOYEE_DEDUCTIONS_AND_BENEFITS_HISTORY DBH ON
    PTH.INST_ID=DBH.INST_ID AND
    PTH.CHECK_DATE=DBH.CHECK_DATE AND
    PTH.CHECK_NO=DBH.CHECK_NO AND
    PTH.EMPLOYEE_ID=DBH.EMPLOYEE_ID
    LEFT JOIN HR_DEDUCTION_AND_BENEFITS DB ON
    DB.INST_ID=DBH.INST_ID AND
    DB.HR_DEDUCTION_AND_BENEFITS_CODE=DBH.HR_DEDUCTION_AND_BENEFITS_CODE
    LEFT JOIN BATCH_QUEUE BQ ON
    PTH.BATCH_QUEUE_ID=BQ.BATCH_QUEUE_ID
    LEFT JOIN BATCH B ON
    B.BATCH_CODE=BQ.BATCH_CODE 
    LEFT JOIN BATCH_PARAMETER BP ON
    BQ.BATCH_QUEUE_ID=BP.BATCH_QUEUE_ID
    AND BP.COLUMN_NAME = 'SUPPRESS_DIRECT_DEPOSIT'
    ------Please change the WHERE condition for date range of the month you need to run this for.
    WHERE PTH.CHECK_DATE >='07/01/2013'
    AND PTH.CHECK_DATE <='07/31/2013'
    and BQ.BATCH_CODE='BAT_PY_PAYCALC'
    and bq.fy=2014
    ORDER BY PTH.INST_ID ,
    PTH.EMPLOYEE_ID,
    DBH.HR_DEDUCTION_AND_BENEFITS_CODE,
    DBH.CHECK_DATE

    Try this code.  The Server name will be the same name when you use SQL Server Management Studio (SSMS).  It is in the login window for SSMS.  I assume you are using SQLSTANDARD (not SQLEXPRESS) which is in the connection string in the code
    below. I also assume you have remote connection allowed in the database.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;
    using System.Data.SqlClient;
    namespace ConsoleApplication1
    class Program
    const string DATABASE = "Enter Database Name Here";
    const string SERVER = "Enter Server Name Here";
    static void Main(string[] args)
    DateTime startDate = DateTime.Parse("07/01/2013");
    string startDateStr = startDate.ToString("MM/dd/yyyy");
    DateTime endDate = new DateTime(startDate.Year, startDate.Month + 1, 1).AddDays(-1);
    string endDateStr = endDate.ToString("MM/dd/yyyy");
    string connStr = string.Format("Server={0}\\SQLSTANDARD;Database={1};Trusted_Connection= True;", SERVER,DATABASE);
    string SQL = string.Format(
    "select\n" +
    " PTH.INST_ID\n" +
    ",PTH.EMPLOYEE_ID\n" +
    ",DBH.HR_DEDUCTION_AND_BENEFITS_CODE,\n" +
    ",replace(DB.DESCRIPTION,',','')\n" +
    ",DB.WITHHOLDING_LIABILITY_ACCOUNT_MASK\n" +
    ",DBH.HR_DEDUCTION_AND_BENEFITS_ID\n" +
    ",DBH.CHECK_DATE\n" +
    ",DBH.CHECK_NO\n" +
    ",DBH.FIN_INST_ACCT_ID\n" +
    ",replace(replace (DBH.COMMENT,CHAR(10),' '),CHAR(13),' ')\n" +
    ",DBH.HR_DEDUCTION_AND_BENEFIT_CYCLE_CODE\n" +
    ",DBH.LENGTH\n" +
    ",DBH.EMPLOYEE_COMPUTED_AMOUNT\n" +
    ",DBH.EMPLOYEE_BANK_ROUTING_NUMBER\n" +
    ",DBH.EMPLOYEE_ACCOUNT_TYPE\n" +
    ",DBH.EMPLOYEE_ACCOUNT_NUMBER\n" +
    ",DBH.EMPLOYER_COMPUTED_AMOUNT\n" +
    ",DBH.EMPLOYEE_GROSS_AMOUNT\n" +
    ",DBH.EMPLOYER_GROSS_AMOUNT\n" +
    ",DBH.PAYROLL_EXCLUDE\n" +
    ",PTH.VOID_DATE\n" +
    ",PTH.BATCH_QUEUE_ID\n" +
    ",B.BATCH_CODE\n" +
    ",BQ.FY\n" +
    ",BQ.END_DATE\n" +
    ",BQ.COMMENTS\n" +
    ",BQ.BATCH_CRITERIA_USED\n" +
    ",BP.COLUMN_VALUE\n" +
    ",PTH.REPLACEMENT\n" +
    ",P.LAST_NAME\n" +
    ",P.FIRST_NAME\n" +
    ",P.MIDDLE_NAME\n" +
    " from PY_EMPLOYEE_TAX_HISTORY PTH\n" +
    " INNER JOIN PERSON_EMPLOYEE PE ON\n" +
    " PE.INST_ID=PTH.INST_ID AND\n" +
    " PE.EMPLOYEE_ID=PTH.EMPLOYEE_ID\n" +
    " INNER JOIN PERSON P ON\n" +
    " PE.INST_ID=P.INST_ID AND\n" +
    " PE.PERSON_ID=P.PERSON_ID\n" +
    " LEFT JOIN HR_EMPLOYEE_DEDUCTIONS_AND_BENEFITS_HISTORY DBH ON\n" +
    " PTH.INST_ID=DBH.INST_ID AND\n" +
    " PTH.CHECK_DATE=DBH.CHECK_DATE AND\n" +
    " PTH.CHECK_NO=DBH.CHECK_NO AND\n" +
    " PTH.EMPLOYEE_ID=DBH.EMPLOYEE_ID\n" +
    " LEFT JOIN HR_DEDUCTION_AND_BENEFITS DB ON\n" +
    " DB.INST_ID=DBH.INST_ID AND\n" +
    " DB.HR_DEDUCTION_AND_BENEFITS_CODE=DBH.HR_DEDUCTION_AND_BENEFITS_CODE\n" +
    " LEFT JOIN BATCH_QUEUE BQ ON\n" +
    " PTH.BATCH_QUEUE_ID=BQ.BATCH_QUEUE_ID\n" +
    " LEFT JOIN BATCH B ON\n" +
    " B.BATCH_CODE=BQ.BATCH_CODE\n" +
    " LEFT JOIN BATCH_PARAMETER BP ON\n" +
    " BQ.BATCH_QUEUE_ID=BP.BATCH_QUEUE_ID\n" +
    " AND BP.COLUMN_NAME = 'SUPPRESS_DIRECT_DEPOSIT'\n" +
    " WHERE PTH.CHECK_DATE >='{0}'\n" +
    " AND PTH.CHECK_DATE <='{1}'\n" +
    " and BQ.BATCH_CODE='BAT_PY_PAYCALC'\n" +
    " and bq.fy=2014\n" +
    " ORDER BY PTH.INST_ID\n" +
    ",PTH.EMPLOYEE_ID\n" +
    ",DBH.HR_DEDUCTION_AND_BENEFITS_CODE\n" +
    ",DBH.CHECK_DATE", startDateStr, endDateStr);
    SqlDataAdapter adapter = new SqlDataAdapter(SQL, connStr);
    DataTable dt = new DataTable();
    adapter.Fill(dt);
    jdweng
    Could you elaborate more on what this code does in general?
    Does it generate a table with the data between specified dates? If so, where is the table shown? 
    Where does one enter in the specified start and end dates on the Web Application? Do I have to create start and end date blanks and link them to the code for it to work?
    Sorry for the inconvenience - I'm just really new at this. Thanks!

  • Email SQL query results from powershell

    I currently have a script that I run every half hour which runs an sql query, and takes the results, and emails them to a group of users.  The script states how many faxes are in a faxmaker queue.  Now, the powers that be would like to add additional
    information, and I wanted to know how to include the additional information in my query. So, here is the script that is working.  I've changed some information to protect the innocent.
    $DATETIME = Get-Date -Format "MM-dd-yyyy [HH:mm:ss]";
    ##### CREATE A LOG FILE AND INSERT A LOG HEADING ;
    $LOG_HEADING = "SHOW FLORIDA INBOUND FAX QUEUES RAN @: " + $DATETIME ;
    Add-Content "E:\psh\LiveScripts\logs\SHOW-FLORIDA-INBOUND-FAX-QUEUE.TXT" $LOG_HEADING ; 
    # get sql dbname  sample
    #email variables
    $EmailFrom = "[email protected]" ;
    $EmailTo = "My Email List" 
    $SqlServer = "MY-SQL-SERVER"
    $SqlCatalog = "FAXmakerArchive"
    $SqlConnection = New-Object System.Data.SqlClient.SqlConnection
    $SqlConnection.ConnectionString = "Server = $SqlServer; Database = $SqlCatalog; Integrated Security = True"
    $SqlConnection.Open()
    $SqlCmd = New-Object System.Data.SqlClient.SqlCommand
    $SqlCmd.CommandText = "SELECT count (DISTINCT fax.ID) DATONA_BEACH_FAX_COUNT FROM
    FM_FAXIN fax WITH (NOLOCK) LEFT OUTER JOIN T_FAX_REVIEW rvw WITH (NOLOCK) ON fax.ID = rvw.IDN_FAX WHERE (fax.RESULT LIKE '%SUCCESS%' OR (fax.RESULT NOT LIKE '%SUCCESS%' AND ATTACH_COUNT > 0)) AND
    ISNULL(rvw.BOOL_IS_COMPLETE, 0) = 0 AND fax.LINE IN (SELECT LINE FROM T_LOCATION_FAX_LINE lne WITH (NOLOCK) WHERE lne.CDE_ACTIVE_FLAG = 1 AND lne.IDN_LOCATION =
    3) AND fax.DATE >   '2013-09-25' "                                        
    $SqlCmd.Connection = $SqlConnection
    $NumberOfFlaInboundFaxes = $SqlCmd.ExecuteScalar()
    $SqlConnection.Close()
    if( $NumberOfFlaInboundFaxes -gt 29)
    #Email Body
    $EmailBody = @"
    There are currently $NumberOfFlaInboundFaxes Faxes in the Florida Inbound Fax Queue (  )`n
    Please Log in and help clear the Queue.  Thank you. `n
    `n`n`n
    The people who recieved this email are: $EmailTo`n`n`n
    From ApexAdmin/SystemScheduler
    $EmailSubject = "There are " + $NumberOfFlaInboundFaxes + " faxes in the Inbound Florida Fax Queue. " + $DATETIME   ;
    #End of Email Body
    #send mail via gmail through powersehll
    $SMTPServer = "smtp.gmail.com" 
    $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587) 
    $SMTPClient.EnableSsl = $true 
    $SMTPClient.Credentials = New-Object System.Net.NetworkCredential("email user", "email password"); 
    $SMTPClient.Send($EmailFrom, $EmailTo, $EmailSubject , $EmailBody)
    Else
    Write-Host "NO ALERT  on $DATETIME `n" -foreground 'DARKGREEN' -background 'WHITE' ;
    #Write-output "There are currently: " $NumberOfFlaInboundFaxes " Faxes in the Florida Fax Queue"
    Write-Host "There are currently "  $NumberOfFlaInboundFaxes  " Files in the Florida fax queue" -foreground 'DarkBLUE' -background 'white'
    Write-Host "SMTP Alert sent to " ( "$EmailTo" ).ToUpper() " on $DATETIME `n" -foreground 'DARKBLUE' -background 'WHITE' ;
    write-Host "WROTE AN ENTRY TO THE LOGFILE.`n" -foreground 'DARKGREEN' -background 'WHITE'
    Now, I'd like to also include this query... also changed information to protect the innocent.
    SELECT u.IDN_USER,      
    u.NAM_LASDBUSER,      
    u.NAM_FIRSDBUSER,      
    r.NAM_ROLE,      
    COUNT(o.IDN_ORDER) ORDER_CNT,      
    COUNT(DISTINCT
    o.IDN_CLIENT) CLIENDBCNT,
    (SELECT IDN_ZONE FROM DBUSER_PREF p WHERE u.IDN_USER = p.IDN_USER) IDN_USER_ZONE 
    FROM DBORDER o WITH (NOLOCK)       
    INNER JOIN DBUSER u WITH (NOLOCK)        
    ON o.IDN_USER_CRTD = u.IDN_USER       
    INNER JOIN DBROLE r WITH (NOLOCK)        
    ON u.IDN_ROLE = r.IDN_ROLE      
    WHERE DATEDIFF(d, GETDATE(), o.DTE_RECORD_CRTD)>=0 AND DATEDIFF(d, GETDATE(), o.DTE_RECORD_CRTD)<=0  
    AND r.IS_INTERNAL_USER = 1
    GROUP BY u.IDN_USER, u.NAM_LASDBUSER, u.NAM_FIRSDBUSER, r.NAM_ROLE, r.IS_INTERNAL_USER 
    ORDER BY u.NAM_LASDBUSER, u.NAM_FIRSDBUSER 
    Thank you in advance for any suggestions, links, etc, you can provide.  I don't mind doing the heavy lifting, ie:  research and reading, just needed to be pointed in the right directions.
    John

    As an example this is more readable but could be improved which would make your adding a section much easier.
    $DATETIME = Get-Date -Format 'MM-dd-yyyy [HH:mm:ss]'
    $LOG_HEADING = "SHOW FLORIDA INBOUND FAX QUEUES RAN @: " + $DATETIME;
    Add-Content "E:\psh\LiveScripts\logs\SHOW-FLORIDA-INBOUND-FAX-QUEUE.TXT" $LOG_HEADING;
    $sql = @'
    SELECT count(DISTINCT fax.ID) DATONA_BEACH_FAX_COUNT
    FROM FM_FAXIN fax WITH (NOLOCK)
    LEFT OUTER JOIN T_FAX_REVIEW rvw WITH (NOLOCK) ON fax.ID = rvw.IDN_FAX
    WHERE
    fax.RESULT LIKE '%SUCCESS%' OR (
    fax.RESULT NOT LIKE '%SUCCESS%' AND ATTACH_COUNT > 0
    AND ISNULL(rvw.BOOL_IS_COMPLETE, 0) = 0
    AND fax.LINE IN (SELECT LINE FROM T_LOCATION_FAX_LINE lne WITH (NOLOCK)
    WHERE lne.CDE_ACTIVE_FLAG = 1 AND lne.IDN_LOCATION = 3) AND fax.DATE > '2013-09-25'
    $template=@'
    There are currently {0} Faxes in the Florida Inbound Fax Queue ( )
    Please Log in and help clear the Queue. Thank you.
    The people who recieved this email are: $EmailTo
    From ApexAdmin/SystemScheduler
    $subject= 'There are {0} faxes in the Inbound Florida Fax Queue. {1:MM-dd-yyyy [HH:mm:ss]}'
    $EmailFrom='[email protected]'
    $EmailTo = "My Email List"
    $SqlServer = "MY-SQL-SERVER"
    $SqlCatalog = "FAXmakerArchive"
    #run query
    $SqlConnection = New-Object System.Data.SqlClient.SqlConnection
    $SqlConnection.ConnectionString = "Server = $SqlServer; Database = $SqlCatalog; Integrated Security = True"
    $SqlConnection.Open()
    $SqlCmd = New-Object System.Data.SqlClient.SqlCommand
    $SqlCmd.CommandText = $sql
    $SqlCmd.Connection = $SqlConnection
    $NumberOfFlaInboundFaxes = $SqlCmd.ExecuteScalar()
    $SqlConnection.Close()
    # build email if needed
    if($NumberOfFlaInboundFaxes -gt 29){
    $EmailBody=$template -f $NumberOfFlaInboundFaxes
    $EmailSubject = $subject -f $NumberOfFlaInboundFaxes,[DateTime]::Now
    $SMTPServer='smtp.gmail.com"'
    $SMTPClient=New-Object Net.Mail.SmtpClient($SmtpServer, 587)
    $SMTPClient.EnableSsl = $true
    $SMTPClient.Credentials = New-Object System.Net.NetworkCredential("email user", "email password");
    $SMTPClient.Send($EmailFrom, $EmailTo, $EmailSubject , $EmailBody)
    }else{
    Write-Host "NO ALERT on $DATETIME `n" -foreground 'DARKGREEN' -background 'WHITE' ;
    Write-Host "There are currently $NumberOfFlaInboundFaxes Files in the Florida fax queue" -foreground 'DarkBLUE' -background 'white'
    Write-Host "SMTP Alert sent to $EmailTo on $DATETIME" -foreground 'DARKBLUE' -background 'WHITE' ;
    write-Host 'WROTE AN ENTRY TO THE LOGFILE.' -foreground 'DARKGREEN' -background 'WHITE'
    \_(ツ)_/

  • Codepage in SQL query?

    Trying to create a form in InfoPath and
    publish it to SharePoint. In the form one field
    receives the code, the rest on the basis of
    code filled by information from the SQL
    database. When filling out forms
    via InfoPath Filler on the client everything works, but if
    the form is filled through a web-interface at SharePoint site - Russian
    letters in the field of the SQL
    query are substituted in the form "?????????".

    Hi Bareika,
    let me summarize a bit,
    if you put the content using infopath form that is not using web interface the issue will appear, but if using infopath filler the issue not reproducible, correct?
    i am not quite sure, if you should add the infopath form language will help to force the language of the form so it will recognize your local language.
    http://www.projectpoint.at/?p=985
    http://social.technet.microsoft.com/Forums/en-US/5485e9c4-a73c-4dec-9949-08070a89a377/saving-a-query-with-unicode-characters-that-cant-be-saved-in-the-current-codepage-how-to-respont?forum=sqlgetstarted
    to debug this, perhaps you can try to grab the culture info from the sharepoint first, so that we can make sure that sharepoint recognize your local language and correctly passed on, for example, 'web.locale'
    Regards,
    Aries
    Microsoft Online Community Support
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • SQL Query converted to PL/SQL?

    I am trying to get my sql query here (which works) converted over to a pl/sql function so I can use an IF / THEN statement to determine whether my 2nd search field has been submitted with something in it.
    My current query:
    select
         comm_Devices.ID,
         comm_Devices.PhonePager,
         comm_Devices.FirstName,
         comm_Devices.LastName,
         comm_Devices.Vendor,
         comm_DeviceType.Device,
         comm_Devices.PhoneNo,
         comm_Devices.Location,
         comm_Vendors.VendorName
    from comm_Devices
         Inner Join comm_DeviceType
              on comm_Devices.DeviceTypeID = comm_DeviceType.ID
         Inner Join comm_Vendors
              on comm_Vendors.vendorId = comm_Devices.vendor
         where
    comm_Devices.LastName LIKE '%' || upper(:P1_SEARCH_LAST_NAME) || '%'
    and comm_Vendors.VendorName LIKE '%' || upper(:P1_SEARCH_VENDOR) || '%'
    What I am wanting to do is convert it to pl/sql so I can do this:
    if :P1_SEARCH_VENDOR != '' then
    q:=q||'and comm_Vendors.VendorName LIKE '%' || upper(:P1_SEARCH_VENDOR) || '%';
    end if;
    Any help would be greatly appreciated!

    You are fairly close to figuring this out. Basically you want to create a Quesry Region of type :SQL Query (Pl/SQL Function Body Returning Sql Query).
    Then as most of the Dynamic query examples shouw you would do something like
    declare
    q varchar2(32767); -- query
    w varchar2(4000); -- where clause
    we varchar2(1) :='N'; -- identifies if where clause exists
    begin
    q := 'select "comm_Devices"."ID", ' ||
    ' "comm_Devices"."PhonePager", ' ||
    ' "comm_Devices"."FirstName",' ||
    ' "comm_Devices"."LastName", ' ||
    ' from "comm_Devices" ' ||
    ' Inner Join "comm_DeviceType" on "comm_Devices"."DeviceTypeID" = "comm_DeviceType"."ID" ' ||
    ' Inner Join "comm_Vendors" on "comm_Vendors"."vendorId" = "comm_Devices". "vendor" ';
    if :P1_SEARCH_VENDOR != '' then
    w := "where statement";
    we := 'Y';
    END IF;
    IF we = 'Y' THEN
    q := q || w;
    END IF;
    return q;
    end;
    This should get you started.
    James
    Message was edited by:
    [email protected]

  • Pulling a value from a field for a SQL statement

    How do i pull the value from a Formatted Text Field into a sql query? Im trying to create an interface to allow a user to put the first name in a field then poll the database for anyone of that name. I do not know of how to get the value that is put in the field by the user.

    Roy, can you give more details about what version of JDeveloper you are using?

Maybe you are looking for

  • Change color for link/website/file link.

    Everytime I create a like to an email or file it seems to be WHITE FONT, but that doesn't work on white background. I have tried so many ways to change the font, but it won't allow it. What do I do to change the color of font to a hyperlink/file etc?

  • How to get the path of local folder in native services in windows phone 8.1 ?

    I used to get the path of local folder path in managed code by following -Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;But now I need to get the local folder path in native services .Please help me o

  • SIMPLE PROBLEM DRIVING ME CRAZZY!!!...please help

    Hi, ive tried searching for this problem all over the forums, but it seems most people have more complicated ones related to this: I have a Jtable in a JtabbedPane... For the JTable i have RESIZE_ALL_COLUMNS chosen...but resize my application, the JT

  • T500 on screen display not working

    I searched, but have not found any other posts with this problem. I re-loaded Windows Vista 64 on a new hard drive, and have re-installed all drivers.  I installed the hotkey driver for on screen display, and the tab appears correctly in the advanced

  • Music moving from windows xp computer to my new macbook?

    I cannot figure out how to transfer my library to my new macbook pro, and it is really frustrating. I cannot stand the share thing because it cannot locate half my songs. Plz hel someone im so lost...