Provide me query for this ?

hi,
i have a data in oracle table .
i need to send this data on text file everyday.
please provide my query to convert data to text at perticular path.
Thanks for your help in advance

Hi,<br>
<br>
Or you can use externale table to unload to a file. Read Unloading and Loading Data with the ORACLE_DATAPUMP Access Driver.<br>
<br>
Nicolas.

Similar Messages

  • Provide sql query for below one

    hi everyone,
    in my source table [finanace_dept] contains two columns [finance_id,r_mature_kd] with 2 million records and sample data given below.
    finance_id r_mature_kd
    1 H
    1 T
    1 T
    2 T
    3 H
    4 S
    4 T
    4 T
    5 X
    6 H
    6 L
    6 L
    6 M
    please provide sql query for below expected output.
    expected output :
    finance_id r_mature_kd
    1 H
    1 T
    4 S
    4 T
    6 H
    6 L
    6 M
    for column finance_id: '1', contains three records, but two distinct r_mature_kd hence it should retrive only two records with H,T
    for column finance_id: '2','3', contains only one record hence this records should not retrive.
    for column finance_id: '6', contains four records, but three distinct r_mature_kd hence it should retrive only two records with H,L,M
    please help on this.

    WITH T(finance_id,r_mature_kd) AS (
    SELECT 1, 'H' FROM DUAL UNION ALL
    SELECT 1, 'T' FROM DUAL UNION ALL
    SELECT 1, 'T' FROM DUAL UNION ALL
    SELECT 2, 'T' FROM DUAL UNION ALL
    SELECT 3, 'H' FROM DUAL UNION ALL
    SELECT 4, 'S' FROM DUAL UNION ALL
    SELECT 4, 'T' FROM DUAL UNION ALL
    SELECT 4, 'T' FROM DUAL UNION ALL
    SELECT 5, 'X' FROM DUAL UNION ALL
    SELECT 6, 'H' FROM DUAL UNION ALL
    SELECT 6, 'L' FROM DUAL UNION ALL
    SELECT 6, 'L' FROM DUAL UNION ALL
    SELECT 6, 'M' FROM DUAL
    SELECT  DISTINCT finance_id,r_mature_kd,C FROM(
    SELECT finance_id,r_mature_kd,COUNT(1) OVER (PARTITION BY finance_id) C
    FROM T
    WHERE C > 1
    ORDER BY 1
    FINANCE_ID
    R_MATURE_KD
    C
    1
    H
    3
    1
    T
    3
    4
    S
    3
    4
    T
    3
    6
    H
    4
    6
    L
    4
    6
    M
    4
    Ramin Hashimzade

  • Two or more productid will be accquired by same customerid, by same shipvia, on the same day of the week of shipped date. i want the simple query for this.

    consider this situation,
     Two or more productid will be accquired by same customerid, by same shipvia, on the same  day of the week of shipped date. i want the simple query for this.
    my tables are  from northwind:
    [orders] = OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight, ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry.
    [orders details] = OrderID, ProductID, UnitPrice, Quantity, Discount.
    i tried some but it is not exact, it gives wrong result.
    select pd.CustomerID,pd.ProductID, pd.no_of_time_purchased, sd.ShipVia, sd.same_ship_count, shipped_day from
    select ProductID,o.CustomerID,COUNT(productid) as no_of_time_purchased
    from orders o join [Order Details] od on o.OrderID=od.OrderID group by ProductID,o.CustomerID
    having count(od.ProductID) >1) pd
    join
    (select OrderID,customerid, shipvia, count(shipvia)as same_ship_count, DATENAME(DW,ShippedDate)as shipped_day from orders
    group by customerid, ShipVia, ShippedDate having COUNT(ShipVia) > 1 ) sd
    on sd.CustomerID=pd.CustomerID

    Hi,
    I think I have a solution that will at least give you a clue how to go about it. I have simplified the tables you mentioned and created them as temporary tables on my side, with some fake data to test with. I have incldued the generation of these temporary
    tables for your review.
    In my example I have included:
    1. A customer which has purchased the same product on the same day, using the same ship 3 times,
    2. Another example the same as the first but the third purchase was on a different day
    3. Another example the same as the first but the third purchase was a different product
    4. Another example the same as the first but the third purchase was using a different "ShipVia".
    You should be able to see that by grouping on all of the columns that you wich to return, you should not need to perform any subselects.
    Please let me know if I have missed any requirements.
    Hope this helps:
    CREATE TABLE #ORDERS
     OrderID INT,
     CustomerID INT,
     OrderDate DATETIME,
     ShipVia VARCHAR(5)
    CREATE TABLE #ORDERS_DETAILS
     OrderID INT,
     ProductID INT,
    INSERT INTO #ORDERS
    VALUES
    (1, 1, GETDATE(), 'ABC'),
    (2, 1, GETDATE(), 'ABC'),
    (3, 1, GETDATE(), 'ABC'),
    (4, 2, GETDATE() - 4, 'DEF'),
    (5, 2, GETDATE() - 4, 'DEF'),
    (6, 2, GETDATE() - 5, 'DEF'),
    (7, 3, GETDATE() - 10, 'GHI'),
    (8, 3, GETDATE() - 10, 'GHI'),
    (9, 3, GETDATE() - 10, 'GHI'),
    (10, 4, GETDATE() - 10, 'JKL'),
    (11, 4, GETDATE() - 10, 'JKL'),
    (12, 4, GETDATE() - 10, 'MNO')
    INSERT INTO #ORDERS_DETAILS
    VALUES
    (1, 1),
    (2, 1),
    (3, 1),
    (4, 2),
    (5, 2),
    (6, 2),
    (7, 3),
    (8, 3),
    (9, 4),
    (10, 5),
    (11, 5),
    (12, 5)
    SELECT * FROM #ORDERS
    SELECT * FROM #ORDERS_DETAILS
    SELECT
     O.CustomerID,
     OD.ProductID,
     O.ShipVia,
     COUNT(O.ShipVia),
     DATENAME(DW, O.OrderDate) AS [Shipped Day]
    FROM #ORDERS O
    JOIN #ORDERS_DETAILS OD ON O.orderID = OD.OrderID
    GROUP BY OD.ProductID, O.CustomerID, O.ShipVia, DATENAME(DW, O.OrderDate) HAVING COUNT(OD.ProductID) > 1
    DROP TABLE #ORDERS
    DROP TABLE #ORDERS_DETAILS

  • How to form a query for this requirment

    Hi Friends,
    I have a database table in which I store the employee data along with his phone number. Now this row of data can repeat for different phone number depending on if it is office phone or home phone or cell phone.
    But in the output of query, I need name of empoyee and other three columns namely "Home Phone", "Office Phone" and "Cell Phone".
    If employee has three rows for each kind of phone, then in the result of query all three columns for phone numbers should be filled, otherwise as many columns should be filled with data as different phone numbers employee has.
    Can any one please post SQL query for this scenario ?
    Thanks in Adavance

    I cannot imagine, that second and third query are
    under any circumstances faster as first one, but i
    can imagine that they are slower You stated that query without the inline view can only be faster. Did you check on optimizer plans or use tkprof to verify your claim?
    A quick check on those two selects
    SELECT object_id, object_type, object_name
      FROM user_objects;
    SELECT object_id, object_type, object_name
      FROM (SELECT object_id, object_type, object_name
              FROM user_objects)
              ;didn't show any changes in the explain plan unter 10g1.
    C.

  • How to write query for this in TopLink ?

    I am doing a simple search in jsp where the search will the based on the choices chosen by user.
    I had given 3 check boxes for those choices.
    The problem is, query will be based on the choice or choices chosed by the user.
    How to write query for this in TopLink ?
    Thanks in Advance..
    Jayaganesh

    Try below solution, it is NOT best solution but might work:
    Declare @Questions TABLE (QuestionID INT, QuestionText Varchar(100))
    INSERT INTO @Questions
    VALUES (1, 'Comment'), (2, 'Score')
    DECLARE @Answers TABLE (authkey INT, QuestionID INT, questiontext VARCHAR(100), answertext VARCHAR(100))
    INSERT INTO @Answers
    VALUES (101, 1, 'comment', 'hi!!'), (101, 2, 'score', '4'), (102, 1, 'comment', 'excellent'), (102, 2, 'score', '5'), (103, 2, 'score', '6'), (104, 2, 'score', '8')
    SELECT
    A.AuthKey
    ,Q.QuestionID
    ,Q.QuestionText
    ,A.AnswerText
    FROM
    @Questions Q
    INNER JOIN @Answers A ON Q.QuestionID = A.QuestionID
    UNION
    SELECT
    A.AuthKey
    ,Q.QuestionID
    ,Q.QuestionText
    ,Null
    FROM
    @Questions Q
    CROSS JOIN @Answers A
    WHERE
    NOT EXISTS (SELECT 1 FROM @Answers SubQry WHERE SubQry.AuthKey = A.AuthKey AND SubQry.QuestionID = Q.QuestionID)
    Output
    AuthKey | QuestionID
    | QuestionText
    | AnswerText
    101 | 1 | Comment | hi!!
    101 | 2 | Score | 4
    102 | 1 | Comment | excellent
    102 | 2 | Score | 5
    103 | 1 | Comment | NULL
    103 | 2 | Score | 6
    104 | 1 | Comment | NULL
    104 | 2 | Score | 8
    Best Wishes, Arbi; Please vote if you find this posting was helpful or Mark it as answered.

  • I want sql query for this output

    hi guys
    could u tell how can i write sql query for this out put
    i have one table like this
    ID ACCOUTID TAX
    1 1 A
    2 1 B
    3 2 C
    4 2 D
    5 3 E
    7 NULL F
    8 NULL G
    MY OUT PUT MUST BE LIKE THIS
    ID AID TAX
    2 1 A
    4 2 D
    7 NULL F
    8 NULL G
    HERE IN THIS OUTPUT I SHOULD HAVE
    MAXIMAM ID VALUE FOR A REPEATED AID VALUES
    AND
    THE ROWS AID VALUES IS NULL ALSO MUST PAPULATED IN THE OUTPUT.
    I KNOW ONE SOLUTION LIKE THIS
    SELECT MAX(ID),AID,TAX
    FROM TABLE T
    GROUP BY AID,TAX
    UNION ALL
    SELECT ID, AIC,TAX
    FROM TABLE T
    WHERE AID IS NULL;
    BUT I WANT SAME RESULT WITH OUT USING LOGICAL OPERATORS.
    COULD U PLZ TELL A SOL.

    Will this help:
    SQL> with t as
      2    (
      3      select 1 ID, 1 ACCOUTID, 'A' TAX from dual union all
      4      select 2, 1, 'B' from dual union all
      5      select 3, 2, 'C' from dual union all
      6      select 4, 2, 'D' from dual union all
      7      select 5, 3, 'E' from dual union all
      8      select 7, NULL, 'F' from dual union all
      9      select 8, NULL, 'G' from dual
    10    )
    11  --
    12  select id, ACCOUTID AID, Tax
    13  from
    14  (
    15    select t.*
    16          ,count(1)       over (partition by t.ACCOUTID) cn
    17          ,row_number()   over (partition by t.ACCOUTID order by id desc) rn
    18    from t
    19  )
    20  where cn > 1
    21  and (rn = 1 or ACCOUTID is null)
    22  /
            ID        AID T
             2          1 B
             4          2 D
             8            G
             7            F
    -- If I leave out the OR condition then you'll get this:
    SQL> ed
    Wrote file afiedt.buf
      1  with t as
      2    (
      3      select 1 ID, 1 ACCOUTID, 'A' TAX from dual union all
      4      select 2, 1, 'B' from dual union all
      5      select 3, 2, 'C' from dual union all
      6      select 4, 2, 'D' from dual union all
      7      select 5, 3, 'E' from dual union all
      8      select 7, NULL, 'F' from dual union all
      9      select 8, NULL, 'G' from dual
    10    )
    11  --
    12  select id, ACCOUTID AID, Tax
    13  from
    14  (
    15    select t.*
    16          ,count(1)       over (partition by t.ACCOUTID) cn
    17          ,row_number()   over (partition by t.ACCOUTID order by id desc) rn
    18    from t
    19  )
    20  where cn > 1
    21* and rn = 1
    SQL> /
            ID        AID T
             2          1 B
             4          2 D
             8            G
    --which follows the description you've given, but not the output

  • How should i write a query for this?

    Hi i give the follwing query to implement the result,
    IT will gives you the result of one country machines information like Total machines failed machines and success machines of their count
    Countyr Name  CountryCode  Total Machines Failed Machines and Succes machines and their perentage
      IT  ITALY
    1000 20
    980    98% 
    like these i want to display the 16 countyr machines information all country information in one palce  like table format
    i will give you the query to the below here it is the combination of powershell code also used here with sql code.
    Code as Country 
    Name as Country
    And below i mentioned OU in bold every where i will put the country code according to the country
    like OU=FR
    Select
            'FR' as 'Code',
            'FRANCE' as 'Name',
            (select COUNT(*) from ADComputersInfo where
        ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
        (select COUNT(*) from ADComputersInfo where
        ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations_Indus,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
        (select COUNT(*) from ADComputersInfo where
        ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Servers,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
        (select COUNT(*) from ADComputersInfo where
        ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
        or
        ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations_Indus,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
        or
        ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Servers,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
        (select count(distinct(cn)) from ADComputersInfo where
        (ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
        or
        ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations_Indus,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
        or
        ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Servers,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com')
        and cn in (select name0 from v_R_System)
        (select count(distinct(cn)) from ADComputersInfo where
        (ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
        or
        ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations_Indus,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
        or
        ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Servers,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com')
        and cn not in (select name0 from v_R_System)
        select count(distinct(cn)) from ADComputersInfo where
        (ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
        or
        ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations_Indus,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
        or
        ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Servers,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com')
        and cn in (select name0 from v_R_System where Client0 =1 and Obsolete0 =0)
        select count(distinct(cn)) from ADComputersInfo where
        (ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
        or
        ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Workstations_Indus,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com'
        or
        ObjectPath like 'LDAP://eur.gad.schneider-electric.com/CN=%,OU=Servers,OU=FR,OU=Countries,DC=eur,DC=gad,DC=schneider-electric,DC=com')
        and cn not in (select name0 from v_R_System where Client0 =1 and Obsolete0 =0)
    So here i pass the County code and country name and OU=FR(assigned country code ) 
    so hw we can all these 3 values in all the query can give me the r8 query for this . And i will get the all 16 country information 
    Ineed exact query hw we can implement..........................................
    I might be excepting lot from our side guys...
    Thanks ! 
    Advanced

    Hi 
    Can you simple post sample data + desired result? Always state what version you are using..
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Can any one send select query for this?

    Hi,
    can any one plese send select query for the following query.please send as early as possible.
    Loop through the I_BSID internal table to fill records in I_OUTPUT.Combine data from I_BSID, I_KNKK, I_KNKK_KNKLI, I_KNA1 and I_KNVV into I_OUTPUT based on the linking conditions .Field Description Source are
    I_OUTPUT-BUKRS     Company code     I_BSID-BUKRS
    I_OUTPUT-KUNNR     Customer number     I_BSID-KUNNR
    I_OUTPUT-NAME1     Customer Name     I_KNA1-NAME1
    I_OUTPUT-KNKLI     Credit account     I_KNKK-KNKLI
    I_OUTPUT-KDGRP     Customer Group     I_KNKK-KDGRP
    I_OUTPUT-KLIMK     Credit Limit     I_KNKK_KNKLI-KLIMK
    I_OUTPUT-KVGR1     Business Unit     I_KNVV-KVGR1
    I_OUTPUT-REBZG     Invoice Number     I_BSID-REBZG
    I_OUTPUT-BLDAT     Invoice Date     I_BSID-BLDAT
    I_OUTPUT-WAERS     Document Currency     I_BSID-WAERS
    I_OUTPUT-DUE_DATE     Due Date     Based on below
    Calculation
      Get the Payment terms days combining I_BSID and I_T052 based on the linking conditions mentioned above.    Note : a) Baseline Date : If baseline date I_BSID-ZFBDT is blank , use the Document Date.b) Payment Term Days :If I_BSID-ZBD3T is not blank, take this as Payment Term Days for Due date calculation.
                       If I_BSID-ZBD3T is Blank, then get payment term days from I_T052 based on I_BSID-ZTERM. If there are more than one record in I_T052 for the given Payment term, get the day part from baseline date and select the first record where the day limit I_T052-ZTAGG is greater than the day part.If I_BSID-ZBD3T is blank and I_BSID-ZTERM is also blank, then take Y000 (Due Immediately) as Payment term and proceed with the above logic. Set the payment term field blank while printing.
    Calculate Due date : For Debits, Determine Due Date = Baseline Date + Payment term Days(not discount days)                                                          For  Credits  Due date = Baseline date.Then, move the amount I_BSID-DMBTR to respective buckets (Not yet Due, Current Due, Past due 1-30, Past Due 31-60 etc.)  Based on the due date.
    Thanks&Regards,
    praveen kumar.A

    HI,
    To get Open Items you can use Function module:
    data:i_items TYPE STANDARD TABLE OF rfpos.
    CALL FUNCTION 'CUSTOMER_OPEN_ITEMS'
    EXPORTING
    bukrs = p_bukrs
    kunnr = wa_customer-kunnr
    TABLES
    t_postab = i_items
    EXCEPTIONS
    no_open_items = 1
    OTHERS = 2.
    Table I_items will have all the open items for that Customer in the given company code.
    Well for Clear Items: Try
    GET_CLEARED_ITEMS or FMITPOFM_CLEARED_ITEMS_GET.
    Hope it helps.
    Manish

  • How  to write select query for this

    Hi,
    I had a html form and in the for i had drop down box and it needs to select multiple values from the drop down box. When i select multiple values then i have to write the SQL select statement  query .
    When i try to write the select statement and trying to run i am getting error.
    select * from Table
    where emo_no = '1,2,3'
    this is how i write query please suggest me how  to write query for selecting multiple values from the drop down box.
    Thanks

    select * from Table
    where emo_no in ( 1,2,3)
    for integer values
    select * from Table
    where emo_no in ('1','2','3')
    for characters
    If we talk about large scale applications that may have millions of records, I would suggest this.
    declare @t table (v int)
    insert into t (v) values (1)
    insert into t (v) valves (2)
    insert into t (v) values (3)
    select *
    from table
         inner join @t t on table.emo_no = t.v
    Using "in" for a where clause is not so bad for filtering on a few values, but if you are filtering a lot of rows and a lot of values (emo_no) the performance degrades quickly for some reasons beyond the scope of this.
    This is just one solution, I'll through this out as well, instead of an in memory (@t) table, doing a disk based temp table (#t) and creating an index on the column "v".
    create table #t (v int)
    insert into #t (v) values (1)
    insert into #t (v) valves (2)
    insert into #t (v) values (3)
    create index ix_t on #t (v)
    select *
    from table
         inner join #t t on table.emo_no = t.v
    drop table #t
    Pardon any syntax errors and careful using a drop statement.
    Sometimes in memory tables work better than disk temp tables, it takes some testing and trial and error depending on your datasets to determine the best solution.
    Probably too much info  ;-)
    Byron Mann
    [email protected]
    [email protected]
    Software Architect
    hosting.com | hostmysite.com
    http://www.hostmysite.com/?utm_source=bb

  • Can anyone create a Query for this?

    Can anyone help me to create a query for the followinf table info?
    I have tried to use joins but no success.
    Table Name: Org
    ID     Severity     Status
    1     Red     New
    2     Yellow     New
    3     Green     Closed
    4     Green     Open
    5     Yellow     Closed
    6     Red     Closed
    7     Red     Closed
    8     Red     Open
    9     Yellow     New
    10     Yellow     Closed
    The result of the query should look like this. The most important thing is that I want this result set in a single query and in this format.
    Severity     Total_Status     Total_Closed
    Red     4     2
    Green     2     1
    Yellow     4     2

    select severity,count(*) tot,sum(decode(status,'closed',1,0)) tot_closed
    from org
    group by severity;
    Not tested..                                                                                                                                                                                                                                                           

  • How to prepare a query for this validation

    I am supposed to implement the below validation using query:
    retrieve emp_no from employee table where emp_desgn='MANAGER' and emp_status='OFFSHORE'
    1. if the emp_no exists display emp_first_name,emp_last_name,emp_remarks.
    2. if the emp_no doesn't exists then display emp_first_name, emp_last_name as blanks and emp_remarks as "EMPLOYEE not available in OFFSHORE'.
    tablename: employee
    can any one please give me the query with this condition. the validation should be implemented in queries and not using functions or procedures.

    i have tried with this
    select emp_no,(
    case emp_no
    when null then emp_first_name
    else 'SPACE'
    end) empfirst_name,
    (case emp_no
    when null then emp_last_name
    else 'SPACE '
    end
    ) emplast_name,
    (case emp_no
    when null then emp_remarks
    else 'EMPLOYEE NOT AVAILABLE IN OFFSHORE'
    end
    ) empremarks
    from employee
    where emp_design='MANAGER' and emp_status='OFFSHORE'
    here emp_no is PK so the emp_no in case statement will execute only if the where condition satisifies. but i am looking the results for the below data.
         EMP_NO     EMP_FIRST_NAME     EMP_LAST_NAME     EMP_DESIGN     EMP_STATUS     EMP_REMARKS
         1     john     Andrey     SRDEVELOPER     ONSITE     DOING GOOD
         2     Peter     Andrey     MANAGER     ONSITE     DOING GOOD
         3     Samuel     Andrey     MANAGER     OFFSHORE     DOING GOOD
         4     Joseph     Andrey     DELIVERYHEAD     OFFSHORE     DOING GOOD
         5     Paul     Andrey     SRARCHITECT     OFFSHORE     DOING GOOD
    i am expecting the results like for emp_no 3 it should display firsname, last name as blank spaces and remarks should be "EMPLOYEE Not availabe in OFFSHORE' but for all it should show the firstnname,lastname,remarks.

  • How to write a query for this data??

    In this table i have column dob which is DATE type,for example 12-jan-89 I want output like this
       Year              Day
    12-jan-89         Thusrs_day
    12-jan-90          Friday
    upto
    12-jan-14        sunday

    krishnagopi wrote:
    No not like that ,I want up to 2014 year
    Ok, so lets say you have table like this
    SQL> create table my_table(dob date);
    Table created.
    SQL> insert into my_table (dob) values( to_date('12-jan-1989', 'dd-mon-yyyy'));
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from my_table;
    DOB
    12-JAN-89
    You can write a query like this
    select dob + (level -1) dob
          , to_char(dob + (level -1), 'fmDay') day_
       from my_table
    connect
         by level <= (dob + interval '25' year) - dob + 1;

  • How to use dynamic query for this ??

    hi , i am new to ABAP. i got a requirement to write  dynamic query for the following code.
    kindly address. two set of queries are same.but condition is different.
    .IF p_psd EQ ' '.
    *C--End of change DF 1232137- (Transport # :CIDK980530 )
    *C--FETCH THE Deliverd Quantiity and Material Number
        SELECT aufnr "ORDER number
               wemng "Quantity of goods received for the order item
               matnr "MATERIAL NUMBER
               pwerk "PLANT
               dauat "Order Type
               FROM afpo
               INTO TABLE t_afpo
               WHERE aufnr IN s_order
               AND   wemng IN s_dqt
               AND   matnr IN s_matnr
               AND   pwerk IN s_plant
               AND   dauat = c_ro.
        IF sy-subrc = 0.
          SORT t_afpo BY aufnr matnr pwerk.
    *C--FETCH THE OBJECT NUMBER
          SELECT aufnr "ORDER number
                 objnr "Object number
                 FROM aufk
                 INTO TABLE t_aufk
                 FOR ALL ENTRIES IN t_afpo
                 WHERE aufnr = t_afpo-aufnr.
          IF sy-subrc = 0.
            SORT t_aufk BY aufnr objnr.
    *C--FETCH THE Target Quantiity
            SELECT aufnr "ORDER number
                   gamng "Total order quantity target quantity
                   FROM afko
                   INTO TABLE t_afko
                   FOR ALL ENTRIES IN t_afpo
                   WHERE aufnr = t_afpo-aufnr
                   AND   gamng IN s_tqt.
            IF sy-subrc = 0.
              SORT t_afko BY aufnr .
            ENDIF.
          ENDIF.
        ELSE.
          MESSAGE text-e03 TYPE c_s. " No data for the selection criteria
          LEAVE LIST-PROCESSING.
        ENDIF.
    *C--Begin of change DF 1232137- (Transport # :CIDK980530 )
      ENDIF.
      IF p_psd EQ c_x.
        SELECT aufnr "ORDER number
               wemng "Quantity of goods received for the order item
               matnr "MATERIAL NUMBER
               pwerk "PLANT
               dauat "Order Type
               FROM afpo
               INTO TABLE t_afpo
               WHERE aufnr IN s_order
               AND   wemng > 0
               AND   matnr IN s_matnr
               AND   pwerk IN s_plant
               AND   dauat = c_ro.
    if sy-subrc = 0.
    *C--FETCH THE OBJECT NUMBER
        IF  NOT t_afpo[] IS INITIAL.
          SORT t_afpo BY aufnr matnr pwerk.
          SELECT aufnr "ORDER number
                 objnr "Object number
                 FROM aufk
                 INTO TABLE t_aufk
                 FOR ALL ENTRIES IN t_afpo
                 WHERE aufnr = t_afpo-aufnr.
          IF sy-subrc = 0.
            SORT t_afko BY aufnr gamng.
          ELSE.
            MESSAGE text-e03 TYPE c_s. " No data for the selection criteria
            LEAVE LIST-PROCESSING.
          ENDIF.
        ENDIF.
        IF NOT t_afpo[] IS INITIAL.
    *C--FETCH THE Target Quantiity
          SELECT aufnr "ORDER number
                 gamng "Total order quantity target quantity
                 FROM afko
                 INTO TABLE t_afko
                 FOR ALL ENTRIES IN t_afpo
                 WHERE aufnr = t_afpo-aufnr
                 AND   gamng <> t_afpo-wemng .
          IF sy-subrc = 0.
            SORT t_afko BY aufnr gamng.
          ELSE.
            MESSAGE text-e03 TYPE c_s. " No data for the selection criteria
            LEAVE LIST-PROCESSING.
          ENDIF.
        ENDIF.
      ELSE.
        MESSAGE text-e03 TYPE c_s. " No data for the selection criteria
        LEAVE LIST-PROCESSING.
      ENDIF.
    Edited by: Thomas Zloch on Jan 5, 2011 1:30 PM please use code tags

    Hi friend,
    Try using MACRO and dynamic WHERE condition.
    Group simialr Select statements under a Macro.
    Build a dynamic where by checking conditions
    Call macro passing dynamic where condition.
    TABLES afpo.
    DATA: str TYPE string.
    *Macro definition
    DEFINE operation.
      select single *
           from afpo into afpo
           where (&1).    " Dynamic condition
    END-OF-DEFINITION.
    *Build dynamic WHERE by checking some conditions
    *If conditon 
    CONCATENATE 'AUFNR = ''000000700008''' 'AND POSNR = ''0001''' INTO str SEPARATED BY space.
    *Else
    CONCATENATE 'AUFNR = ''000000700008''' 'AND POSNR = ''0002''' INTO str SEPARATED BY space.
    *Endif.
    *Call Macro passing dynamic WHERE condition
    operation str.

  • Give me Sql Query for this problem?.  Please Help Me........

    This is my exact requirements
    My PNO table formart is
    PNO PDate PCount
    P001 08/27/05 20
    P001 08/29/05 10
    P002 08/27/05 20
    P003 08/28/05 20
    P003 08/28/05 20
    I want to display the total (PCount) PNumber for this week.
    PNo Sat (27th) Sun(28th) Mon(29th) .........Fri(2/09/2005)
    P001 20 0 10 0
    P002 20 30 0 0
    P003 0 40 0 0
    or at least i want to display, i mean if there is no record for P003 on starturday, it will display 0.
    PNo Sat (27th)
    P001 20
    P002 20
    P003 0
    first iam getting distinct PNo for this week, and check whether these number occurs on saturday if occur then display count otherwise display 0
    Millons of thanks in advance...
    Message was edited by:
    user448874

    EZECASH@ORCL> select * from pno_table;
    PNO  PDATE         PCOUNT
    P001 27-AUG-05         20
    P001 29-AUG-05         10
    P002 27-AUG-05         20
    P003 28-AUG-05         20
    P003 28-AUG-05         20
    P001 02-SEP-05         10
    P001 03-SEP-05         15
    P002 03-SEP-05         10
    P002 04-SEP-05         10
    9 rows selected.
    EZECASH@ORCL> select next_day(trunc(sysdate)-7,'sat') d1,next_day(trunc(sysdate)-7,'sat')+1 d2,next_day(trunc(sysdate)-7,'sat')+2 d3,
      2    next_day(trunc(sysdate)-7,'sat')+3 d4,next_day(trunc(sysdate)-7,'sat')+4 d5,next_day(trunc(sysdate)-7,'sat')+5 d6,
      3    next_day(trunc(sysdate)-7,'sat')+6 d7
      4  from dual
      5  /
    D1        D2        D3        D4        D5        D6        D7
    27-AUG-05 28-AUG-05 29-AUG-05 30-AUG-05 31-AUG-05 01-SEP-05 02-SEP-05
    EZECASH@ORCL> select pno,sum(decode(trunc(pdate),d1,pcount,0)) day1Sum, sum(decode(trunc(pdate),d2,pcount,0)) day2Sum,
      2  sum(decode(trunc(pdate),d3,pcount,0)) day3Sum,sum(decode(trunc(pdate),d4,pcount,0)) day4Sum,
      3  sum(decode(trunc(pdate),d5,pcount,0)) day5Sum,sum(decode(trunc(pdate),d6,pcount,0)) day6Sum,
      4  sum(decode(trunc(pdate),d7,pcount,0)) day7Sum
      5  from  pno_table,
      6  (select next_day(trunc(sysdate)-7,'sat') d1,next_day(trunc(sysdate)-7,'sat')+1 d2,next_day(trunc(sysdate)-7,'sat')+2 d3,
      7    next_day(trunc(sysdate)-7,'sat')+3 d4,next_day(trunc(sysdate)-7,'sat')+4 d5,next_day(trunc(sysdate)-7,'sat')+5 d6,
      8    next_day(trunc(sysdate)-7,'sat')+6 d7
      9  from dual) w
    10  where pdate >= next_day(trunc(sysdate)-7,'sat')
    11  group by pno
    12  /
    PNO     DAY1SUM    DAY2SUM    DAY3SUM    DAY4SUM    DAY5SUM    DAY6SUM    DAY7SUM
    P001         20          0         10          0          0          0         10
    P002         20          0          0          0          0          0          0
    P003          0         40          0          0          0          0          0
    EZECASH@ORCL>

  • How to write a sql query for this condition?

    i have one table with columns v_sub,v_visit and v_date and the structure is like this
    v_sub v_visit v_date
    1 visit-1 01-mar-09
    1 visit-2 05-mar-09
    1 visit-3 17-mar-09
    2 visit-1 04-feb-09
    2 visit-2 12-mar-09
    2 visit-3 20-mar-09
    i want to write a query which check weather it is in chronological order or not.(for v_sub,v_visit and v_date should be in chronological order as above)
    and i want to check the condition as below:
    v_sub v_visit v_date
    1 visit-1 01-mar-09
    1 visit-2 05-feb-09
    1 visit-3 17-mar-09
    2 visit-1 04-feb-09
    2 visit-2 12-jan-09
    2 visit-3 20-mar-09
    Thanks in advance

    use LAG function to get the previous date
    SQL> -- sample data
    SQL> with t
      2  as
      3  (
      4     select 1 v_sub, 'visit-1' v_visit, to_date('01-mar-09','dd-mon-yy') v_date from dual union all
      5     select 1, 'visit-2', to_date('05-mar-09','dd-mon-yy') from dual union all
      6     select 1, 'visit-3', to_date('17-mar-09','dd-mon-yy') from dual union all
      7     select 2, 'visit-1', to_date('04-feb-09','dd-mon-yy') from dual union all
      8     select 2, 'visit-2', to_date('12-mar-09','dd-mon-yy') from dual union all
      9     select 2, 'visit-3', to_date('20-mar-09','dd-mon-yy') from dual
    10  )
    11  -- end of sample data
    12  select v_sub, v_visit, v_date, lag(v_date) over(partition by v_sub order by v_visit, v_date) v_previous_date
    13    from t
    14  /
         V_SUB V_VISIT V_DATE    V_PREVIOU
             1 visit-1 01-MAR-09
             1 visit-2 05-MAR-09 01-MAR-09
             1 visit-3 17-MAR-09 05-MAR-09
             2 visit-1 04-FEB-09
             2 visit-2 12-MAR-09 04-FEB-09
             2 visit-3 20-MAR-09 12-MAR-09
    6 rows selected.Now you can check if the previous_date is less than v_date

Maybe you are looking for

  • NUMBER OF PREVIOUS ITEMS

    In the Options>SMS>Number of previous items. Can anyone tell me what this function does? What the number of entries does? Solved! Go to Solution.

  • Adding search help (F4) for a screen field in standard screen of VA02

    Dear Gurus, I need to add a Search Help (F4) to a Standard Screen Field VBAK-VSNMR_V in the standard Screen of VA01/Va02.....Can anyone please guide me how it can be done. Regards Sajid Edited by: shaik sajid on Feb 2, 2009 8:38 AM

  • Backup gone wrong

    I had to restore iTunes from backup over the weekend. My PC had to be reformatted, but I backup everything to an external HD. So I have restored, and tried all the steps in the KB article about getting your library back up and running. Unfortunately,

  • IMac internet sharing with WinXP

    Hello everyone, I'd like to post a little issue I found with my new iMac (OS X 10.5.7). I had it connected to the internet, directly through the ethernet cable modem. I used the Internet Sharing option to share the connection through Airport. I have

  • Delete an entire project in Premiere Pro CS5.5

    HI: How can I delete an entire project in PP CS5.5. I'm worried about deleting because I have a bunch of projects saved and I'm not sure how they are saved and if they are scattered all over the HDD's. I don't want to delete something that I'm using.