HELP with select statement

Hello all and thanks in advance. I'm sorry if I am posting this in the wrong section. Could someone show me how I can write this statement in oracle? for now, I have as an SQL statement in asp.net VB. Any help would be greatly appreciated!

SELECT DISTINCT EQP_SERIAL_EQP, EQP_TYP_EQP in #TEMP
of EQP_BASE
where EQP_LOCAL_EQP = right (' 000000000000' + ' "& DDLTECHNUMBERS." ") Text & "(', 16) AND EQP_STAT_EQP IN ('C', ' t ',' K')"
EQP_TYP_EQP GROUP, EQP_SERIAL_EQP
SELECT DISTINCT EQP_TYP_EQP AS TYPE, count (1) AS COUNTY GROUP #TEMP BY EQP_TYP_EQP
TRUNCATE TABLE #TEMP
DROP TABLE #TEMP

Thank you
E

Hello

SELECT DISTINCT EQP_SERIAL_EQP, EQP_TYP_EQP Into #TEMP
from EQP_BASE
where EQP_LOCAL_EQP = right('000000000000' + '" & DDLTECHNUMBERS.Text & "', 16) AND EQP_STAT_EQP IN ('C','T','K')
GROUP BY EQP_TYP_EQP, EQP_SERIAL_EQP
SELECT DISTINCT EQP_TYP_EQP AS TYPE, count(1) AS COUNT from #TEMP GROUP BY EQP_TYP_EQP

SELECT DISTINCT temp. EQP_TYP_EQP AS TYPE,
Count (1) AS COUNT
Of
(
SELECT DISTINCT EQP_SERIAL_EQP, EQP_TYP_EQP
of EQP_BASE
where EQP_LOCAL_EQP = substr ("000000000000' |") DDLTECHNUMBERS. Text 1: 16)
AND EQP_STAT_EQP IN ('C', 'T ', ' K')
EQP_TYP_EQP GROUP, EQP_SERIAL_EQP
) temp
Temp GROUP BY. EQP_TYP_EQP

-Pavan Kumar N

Tags: Database

Similar Questions

  • Help with SELECT - select the range of numbers

    Hello
    I need assistance with the SELECT statement. I want to choose Dates today and ending 30 days back. If the result would be like:
    TRUNC(SYSDATE)
    TRUNC(SYSDATE) - 1
    TRUNC(SYSDATE) - 2
    TRUNC(SYSDATE) - 3
    .
    .
    .
    TRUNC(SYSDATE) - 30
    I was thinking about truncated SYSDATE simply select in the first column and second column number 0, 1, 2... 30 then I'd just do a difference first column - second. But how to choose such sequence of numbers? I don't want to choose every number (date) in the select distinct statement, then Union them.

    Does anyone have an idea?
    Thanks for the help, Dan
    SQL> select trunc(sysdate) - level + 1 as dt
      2  from dual
      3  connect by level <= 31
      4  ;
    
    DT
    -----------
    07/01/2013
    06/01/2013
    05/01/2013
    04/01/2013
    03/01/2013
    02/01/2013
    01/01/2013
    31/12/2012
    30/12/2012
    29/12/2012
    28/12/2012
    27/12/2012
    26/12/2012
    25/12/2012
    24/12/2012
    23/12/2012
    22/12/2012
    21/12/2012
    20/12/2012
    19/12/2012
    
    DT
    -----------
    18/12/2012
    17/12/2012
    16/12/2012
    15/12/2012
    14/12/2012
    13/12/2012
    12/12/2012
    11/12/2012
    10/12/2012
    09/12/2012
    08/12/2012
    
    31 rows selected
     
    
  • Need help with select this range of months with flexible first date

    Hi all

    I am creating a selection range months (will be in a WITH clause), for a report view monthly data. But the first months start date may be any date. (Not necessarily the first date of the month)
    Examples:

    Report of input parameters:

    Start date: 10/08/12
    End of month: December 2012

    I tried to build a SELECT that will list
    Month_Start, Month_End
    10/08/12, 10/31/12
    11/01/12, 11/30/12
    12/01/12, 31/12/12

    OR
    Month_Start, Next_Month
    10/08/12, 11/01/12
    11/01/12, 12/01/12
    12/01/12, 01/01/13


    End of the month being optional, if no select value lists only
    10/08/12, 11/01/12


    Details of database is Oracle
    Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production
    PL/SQL Release 11.1.0.7.0 - Production

    My code is far
    VARIABLE  P50_START_DATE  VARCHAR2 (10)
    VARIABLE  P50_END_MONTH    VARCHAR2 (10)
     
    EXEC  :P50_START_DATE  := '10/10/2012';
    EXEC  :P50_END_MONTH   := '31/12/2012';
      
     
      SELECT  to_char(:P50_START_DATE) AS start_date
            ,  ADD_MONTHS( TRUNC(to_date(:P50_START_DATE,'DD/MM/YYYY'),'MONTH'), 1) AS next_month
      FROM dual
      union
    
       SELECT to_char(ADD_MONTHS( TRUNC(to_date(:P50_START_DATE,'DD/MM/YYYY'),'MONTH'), ROWNUM-1)) AS start_date
       ,      ADD_MONTHS( TRUNC(to_date(:P50_START_DATE,'DD/MM/YYYY'),'MONTH'), ROWNUM) AS next_month
       --, rownum
       from all_objects
       where
       rownum <= months_between(to_date(NVL(:P50_END_MONTH, :P50_START_DATE),'DD/MM/YYYY'), add_months(to_date(:P50_START_DATE,'DD/MM/YYYY'), -1))
       and rownum > 1
    If I put the comment - on the line and rownum > 1, as
    -- and rownum > 1
    The result I get is
    START_DATE                     NEXT_MONTH                
    
    01/10/12                       01/10/12                  
    01/11/12                       01/11/12                  
    01/12/12                       01/01/13                  
    10/10/2012                     01/11/12    
    But when I try to remove the double off period (the first month) by restricting rownum, it do not return all the lines for the second selection at all. The result I get is:
    START_DATE                     NEXT_MONTH                
    
    10/10/2012                     01/11/12    
    Can anyone tell what is wrong with the statement select?

    Thank you very much in advance,
    Ann

    Queries line use:

    SQL> VARIABLE  P50_START_DATE  VARCHAR2 (10)
    SQL> VARIABLE  P50_END_MONTH    VARCHAR2 (10)
    SQL>
    SQL> EXEC  :P50_START_DATE  := '10/10/2012';
    
    PL/SQL procedure successfully completed.
    
    SQL> EXEC  :P50_END_MONTH   := '31/12/2012';
    
    PL/SQL procedure successfully completed.
    
    SQL> SELECT  CASE LEVEL
      2            WHEN 1 THEN TO_DATE(:P50_START_DATE,'DD/MM/YYYY')
      3            ELSE TRUNC(ADD_MONTHS(TO_DATE(:P50_START_DATE,'DD/MM/YYYY'),LEVEL - 1),'MM')
      4          END MONTH_START,
      5          LAST_DAY(ADD_MONTHS(TO_DATE(:P50_START_DATE,'DD/MM/YYYY'),LEVEL - 1)) MONTH_END
      6    FROM  DUAL
      7    CONNECT BY ADD_MONTHS(TO_DATE(:P50_START_DATE,'DD/MM/YYYY'),LEVEL - 1) <= TO_DATE(:P50_END_MONTH,'DD/MM/YYYY')
      8  /
    
    MONTH_STA MONTH_END
    --------- ---------
    10-OCT-12 31-OCT-12
    01-NOV-12 30-NOV-12
    01-DEC-12 31-DEC-12
    
    SQL> 
    

    SY.

  • Need help with select distinct in group by

    RDBMS 10 g 2

    I have tried what a separate select statement with an order by and having looked on the internet and try different examples, I was unsuccessful.

    Here is the code work (not tri - I want to sort by pps.last_name but I can't seem to make it work).
    select distinct pps.last_name || ', ' ||pps.first_name || ' ' ||pps.middle_initial || '.' d, 
           emple_no r
      from cobr.vw_pps_payroll pps,
           projman pm
     where term_date is null
       and department = '0004400000'
       and pm.eid != pps.emple_no

    Given that the family name is the leading role or your concatenated column 1, how about this:

    select distinct pps.last_name || ', ' ||pps.first_name || ' ' ||pps.middle_initial || '.' d,
           emple_no r
      from cobr.vw_pps_payroll pps,
           projman pm
     where term_date is null
       and department = '0004400000'
       and pm.eid != pps.emple_no
    order by 1
    
  • Need help with update statement to be used in the stored procedure

    I have the following update statement and I get "ORA-06512. Someone of you can help me.

    ----
    UPDATE MO X SET X.MOMODEL = (SELECT Y.MOMODEL FROM MO Y WHERE Y.MOID = A_TEMP_INT3)
    WHERE X.MOID in (UPDATE MO X SET X.MOMODEL = (SELECT Y.MOMODEL FROM MO Y WHERE Y.MOID = A_TEMP_INT3)
    WHERE X.MOID in (A_TEMP_INT1, (select assocchild from mo_association
    Connect prior assocchild = assocparent
    Start with assocparent = A_TEMP_INT1)); (by selecting assocchild in mo_association
    Connect prior assocchild = assocparent
    Start with assocparent = A_TEMP_INT1));
    ----

    Note: A_TEMP_INT1 and A_TEMP_INT3 are the values of cursor and is assigned to numeric values in the code.


    Thanks for all the help in advance.

    Kind regards
    REDA
    WHERE X.MOID IN
     (SELECT ASSOCCHILD   FROM MO_ASSOCIATION
          CONNECT BY PRIOR ASSOCCHILD = ASSOCPARENT
         START WITH ASSOCPARENT = A_TEMP_INT1
         UNION
      SELECT A_TEMP_INT1 FROM DUAL );
    

    Should work.
    VR,
    Sudhakar B.

  • Help with Select decodes round

    Hi, if someone could help me with this. I need to round up all these numbers in the DECODE, but without repeating the CYCLE.
    Works in this way:

    SELECT the title 'Title', 'class, retail "price."
    DECODE (category,
    'COMPUTER', (ROUND(retail * 1.1,2)),
    'CONDITION', (ROUND(retail * 1.15,2)),
    "SELF HELP", (ROUND(retail * 1.25,2)),
    (ROUND(retail * 1.03,2))) "" Revised price.
    Books
    ORDER BY category, title;

    But I need something more like this:

    SELECT the title 'Title', 'class, retail "price."
    DECODE (ROUND ((category,
    'COMPUTER', retail * 1.1,.
    'FITNESS', detail * 1.15,.
    "SELF-HELP", detail * 1.25,.
    Retail * 1.03) 'Revised price'), 2)
    Books
    ORDER BY category, title;

    so this TOUR is not repeated more than once... they all need to be rounded up to two decimal places.
    any help would be great. Thank you

    your second is close. You need complete the decode statement. Like this:

    SELECT title "Title", category "Category",retail "Current Price",
           ROUND(DECODE(category, 'COMPUTER',retail * 1.1,
                                  'FITNESS', retail * 1.15,
                                  'SELF HELP', retail * 1.25,
                                  retail * 1.03),2) "Revised Price"
    FROM books
    ORDER BY category, title;
    

    Note that the alias (I guess) revised procedures must go outside to decode and the series.

    John

  • JavaScript: Help with IF statement

    I'm not familiar with Java and I fight with this IF statement and I can't make it work.  I'm sure it's something pretty basic.  Can anyone help?  I tried everything, seeminly.  In this example below I'm checking if the data that the user has entered in the field of the AAA FAVOR and if it is then put in place a message and if not then set up another message.  My top node in my hierarchy is data, and then I have a MainSubform and a Contact02Subform.  I have this code attached to a button and notthing happens when I click the button.  If I delete the statement and have just the box of message by itself, then it will display the message box.  So I know that's my statement and I'm sure it's simple.  Help please?

    If

    (xfa.resolveNode("xfa.form.data.MainSubform.Contact02Subform.FAVOR").rawValue == 'AAA')

    {

    xfa.host.messageBox ("my IF");

    else ;

    xfa.host.messageBox ("my ELSE");

    endif;

    Try this.

    If (rawValue. xfa.resolveNode("xfa.form.data.MainSubform.Contact02Subform.FAVOR") is 'AAA')

    {

    xfa.host.messageBox ("my IF");

    }

    on the other

    {

    xfa.host.messageBox ("my ELSE");

    }

    endif is used in FormCalc are generally not in JavaScript.

    Thank you

    Sidonie.

  • Help with If statement emergency please!

    Hello world

    I wonder if someone can tell me why flash seems to ignore my statements if, whenever I try to use an it ignores the condition and fair actions command. Its driving me crazy. I don't know that I do something wrong, I just can't cope.

    I put;

    on (release) {}

    If ((_root.eyeshadow = "Rose") & & (_root.lipy = 'Pink')) {}
    _root.correct._alpha = 100;
    }
    }

    It seems just action _root.correct._alpha = 100;
    even when a different color is selected.
    I was wondering can flash read a variable from another script, because otherwise it will not know what eyeshadow and lípy are. I get no error message though.

    Please help someone!
    Thank you
    Stacy.x.

    is this variable declared at the root?

    like you did here
    _root.eyeshadow1._alpha = 100;

    I'm not sure because I don't know what you have

  • NEED HELP WITH SELECTION was GOOD AND good POWER (HP dc7900 Convertible Minitowers) MARKET

    Hello! I have a HP dc7900 in Minitour Convertible with the following specifications:

    Core 2 Quad q9400 2, 66 GHz

    nVidia GeForce GT430 1 GB

    Elpida 2x2gb RAM 800 mhz (I'll add 2 x 2 earlier so I can get 8 GB)

    Card mother HP 3032 h

    Block POWER 365 stock w.

    So I was planning to buy a Radeon HD 7770 (MSI, Palit, or Sapphire) because I have a small budget and this seems to be a good fit, but there's better food, so I was wondering if there are more good, good markets that would be able to manage my PC (with the new gpu, 8 GB of ram and a single PCIe 6-pin). I also have an MS PRO-550 Industrial, ATX in my old PC and I wanted to add, but I just discovered that it is very bad and that there actually 200w (not 550) :/ Any help would be appreciated P.S I found 'used' Corsair CMPSU-400cx and an Antec SU - 430 then how do get?

    I see that your desired card has a minimum 400W power quantity, but I recommend moving more to a 500W or 600W for handling units your other hardware too although a little extra space so you would be upgraded.

    I am very pleased with the PSU Corsair, I recently installed a CX500 in my machine, although in a smaller case, you need good cables.

    I hope this helps.

  • Help with If statement in menu drop down

    Hello

    I'm not too familiar with the implementation of the custom scripts and I was wondering if someone here might be able to help me. I'm figuring a discount in the form of price value if the customer applies for a military/senior discount, but if the customer is not applicable I want the field to calculate the total without factoring in a shed.

    I took a screenshot and circled the field that concerns me in red. If someone could help I would be very happy!

    PricingFormPDF.jpg

    Suppose that the names of the fields are "Subtotal", "Discount military" and "military discount amount.

    You can use this code as the custom of the latter calculation script:

    if (this.getField("Military Discount").value=="Yes") event.value = Number(this.getField("Subtotal").value) * 0.05;
    else event.value = "";
    
  • Help with selection lists in the classic report

    Hello

    I work with APEX 4.1. Oracle 11.

    I have a simple and classic report with 4 columns (username, role, reading, updating). The columns of the reading and the update are select list with values of 'Yes', 'no '.

    Report looks like this:

    User role name read the update
    JSmith Admin Yes Yes
    LJones Dev yes no


    My requirement is that when the user selects Yes the update select list, the value of the associated column in the reading should change Yes as well for this particular user name. Change must occur after Yes is selected in the list select update.

    Im not very strong with javascript, but for testing purposes I applied: onchange = "alert ('hi'); "in the update column. When I make a change to the update select list, the alert returns to its position.

    Can anyone suggest how I can implement the change to the value of associated reading of Yes if the selected update value is Yes, for this particular line.

    Thank you
    Laura

    Here is an example of work for you, copy and change the javascript that you need.

    To find names of columns to the select list of apex > address view the source of your page report and use them accordingly in the JS

    http://Apex.Oracle.com/pls/Apex/f?p=46417:11

    Test/test connection

    function test(pThis) {
     //get the curren row index on change
     var currIndex = $('select[name="'+pThis.name+'"]').index($x(pThis.id));
     // check current items value (return value of lov)
     if (pThis.value=='Yes') {
      // if true change the value of column f01 at same row index
      $('select[name="f01"]')[currIndex].value = 'Yes';
     }
     else {
       //do something else
      }
    }
    
    //In the element attributes of update column add
    onchange="javascript:test(this);"
    
  • helps the select statement

    Hi experts,

    I have a test table
    create table test
    (order_no varchar2(40),
    assignment varchar2(4000)
    );
    
    insert into test values('A1','XYZ (09092010);');
    insert into test values('W1','ABC (01012010); BCA (01022010);');
    
    insert into test values('W2','CDE (12122011); EFG (01062011); GHI (06072010);');
    
    insert into test values('W3','XYZ (06062010); GHI (03012011); BNM (04062010); JFK (04072010);');
    
    insert into test values('W4','GHJ (02032010); TRR(08082010); RTY (01022010); YUO(01012011); WOO(02012010);');
    I want to eliminate (date); Get the other character

    -case when

    First row has a character with date separated, then the first character must be in first column (XYZ) assignment

    Second row has two character with separate date then first character should in the first column of assign (ABC) and second character must be on a second assignment column (BCA)


    the result should look like:


    Order_no Assignmnet frst_assign second_assign third_assign fourth_assign fifth_assign
    A1 XYZ (09092010); XYZ

    W1 ABC (01012010); BCA (01022010); ABC BCA

    W2 CDE (12122011); EFG (01062011); INTERNAL AFFAIRS (06072010); CDE EFG GHI
    W3 XYZ (06062010); INTERNAL AFFAIRS (03012011); BNM (04062010); JFK (04072010); XYZ GHI BNM JFK
    W4 GHJ (02032010); SRT (08082010); RTY (01022010); YUO (01012011); WOO (02012010); GODU DRT RTY YUO WOO


    Thanks in advance

    sb92075 wrote:
    If data & table have been standardized, this challenge becomes moot.
    Fix lame design!

    but... lame design is fun! I have not had a chance to use regular expressions for the first time this month, if the OP database has been designed properly using a relational model.

    try this one:

    select ASSIGNMENT,
    ltrim(REGEXP_SUBSTR(ASSIGNMENT,';? ?[[:alnum:]]+',1,1),'; ') FIRST_ASSIGN
    ,ltrim(REGEXP_SUBSTR(ASSIGNMENT,'; [[:alnum:]]+',1,2),'; ') SECOND_ASSIGN
    ,ltrim(REGEXP_SUBSTR(ASSIGNMENT,'; [[:alnum:]]+',1,3),'; ') THIRD_ASSIGN
    ,ltrim(REGEXP_SUBSTR(ASSIGNMENT,'; [[:alnum:]]+',1,4),'; ') FOURTH_ASSIGN
    ,ltrim(REGEXP_SUBSTR(ASSIGNMENT,'; [[:alnum:]]+',1,5),'; ') fifth_assign
    from test;
    
  • Need help with SQL statement

    So I am new to SQL and ORACLE. I need to know how to do the commands below in a single statement. I did it in two here, but I have no idea how do it in one. Any ideas?

    ALTER TABLE books
    ADD Catcode VARCHAR2 (3);

    ALTER TABLE books
    ADD CONSTRAINT books_catcode_fk FOREIGN KEY (catcode)
    REFERENCES (catcode) category;

    Any help appreciated ^^
    SQL> ed
    Wrote file afiedt.buf
    
      1  alter table books
      2    add( catcode varchar2(3),
      3         constraint books_catcode_fk
      4            foreign key( catcode )
      5*        references category( catcode ) )
    SQL> /
    
    Table altered.
    

    Justin

  • Can someone help with this statement?

    SELECT count (*) from document_master
    where PROJ_id = "888"
    and doc_status = 'I '.
    and rec_update_date like ' % 08'.
    rec_update_date desc order


    This gives result numbered for a column that ends in 08.
    Can someone tell me how to generate a list of 09, 08, 07, 06, etc...

    I tried
    and rec_update_date like ' %-08' or rec_update_date like ' %-09'.
    I also tried
    and rec_update_date like ' % 08'.
    and rec_update_date like ' %-09'.

    neither work.

    I appreciate all help.

    Thank you

    What is the rec_update_date column data type? It if DATE, right? If so, you question is completely wrong. Condition rec_update_date like ' %-08' force the implicit conversion from DATE to string using default data format that's in your case, be MON-JJ-AA and dependent client session.» So if the user whose session has different default date format runs your code it will not get the expected results:

    SQL> alter session set nls_date_format = 'DD-MON-YY';
    
    Session altered.
    
    SQL> select sysdate from dual;
    
    SYSDATE
    ---------
    31-JUL-09
    
    SQL> select sysdate from dual where sysdate like '%-09';
    
    SYSDATE
    ---------
    31-JUL-09
    
    SQL> alter session set nls_date_format = 'MM/DD/YYYY';
    
    Session altered.
    
    SQL> select sysdate from dual;
    
    SYSDATE
    ----------
    07/31/2009
    
    SQL> select sysdate from dual where sysdate like '%-09';
    
    no rows selected
    
    SQL> 
    

    Looks like you want to select counties of line for each year. If so, use:

    select trunc(rec_update_date,'YYYY'),count (*) from document_master
    where PROJ_id = '888'
    and doc_status = 'I'
    group by trunc(rec_update_date,'YYYY')
    order by trunc(rec_update_date,'YYYY') desc
    /
    

    SY.

  • Help with mousedown State in phone version

    Hello

    I am having some problems affecting the mousedown State in the version of phone of my site.

    You can check it out here: www.betterargentina.com

    On the portfolio page, I have some information hidden behind the bottle and when someone clicks on the bottle that he was supposed to appear in the text. Here, it works only in some bottles, in anothers nothing happens and in a few the right image is empty, but it has quite the same way.

    Someone might know why this is happening or know another way I can program the phone interactions?

    Thanks in advance.

    Rita Gomes

    Using the effects Panel, change the opacity for the blocks of text inside buttons from 0 to 100% State in the rollover State.

Maybe you are looking for