SQL: delete command for duplicate rows for any particular user

Hello Experts,
I've a table like below, where 'X' is the primary key.
X Y Z
a | p | amit
b | q | amit
c | r | amit
d | p | amit
e | s | amit
f | p | manish
g | t | manish
h | p | akash
Objective:
Find and delete all the rows who has duplicates (for 'Y') for user 'amit'. Here, 'p' is given as an example. We don't know what the actual duplicate value is.
Expected Result:
rows 'a' and 'd' should be deleted
SQL:
===
select Y, count(*) from T where Z='amit'
group by Y
having count(Y) >1
This query works to get the duplicates and the total count.
However, how to delete these rows from actual table is the question. Please note that I need to run this query through a JDBC program.
Thanks,

You could try
delete from tableb
  where x not in ( select max(s.x)
                    from tableb s
                    group by s.y, s.z);The easiest way I've found to build these sort of statements is to write a select first which gives you the records you want ( or not want in this case ). Then to write the delete round that statement.
Edited by: Nigel Ren on 07-May-2011 01:23

Similar Messages

  • ALV Weddynpro : Text color for a row(for a particular record)

    Hello Friends,
    Situation : Webdynpro App utilizing re-usable ALV component to Edit(changed/modify) Employee records.
                     I have used to the class cl_salv_wd_uie_a_input to make certain columns read_only and colored(cell background only).
    My requirement :
    Suppose there are 4  rows and based on  if a certain condition is staisfied(lets say 2 rows), then i have to  changed the color ONLY THE TEXT(to RED). There is certain meaning for the rows for such records which users can easily interpret.
    I have tried to used CL_SALV_WD_UIE_TEXT_VIEW(which i have successfully color coded the texts),  but i lose the editing capabilities.
    The webdynpro App uses a EDITABLE-ALV meaning that, user can  insert/modify/delete records and save them in the DB.
    Is there anyway to have both this features using above said situations and consequences?
    OR
    Pls share any workaround if anyone has tried this before?
    Regards
    Vinay.
    Example.
      PERNR
      COL1
      COL2
      102984
      UYYER
      IIIELX
      102983
      DFKLJJ
      DOFUOU
      102985
      DOFJDOFU
      DFOIUOIU
      102988
      DFOADSFUOU
      OSDUFOU

    Hi,
    We can assign semantic colors only to text view fields. So in this case since you are forcibly changing the  view to text view, for text coloring, we are losing the edit fields capabilities. Instead setting the type of field( text view / input view ) based on the your condition could be best, so that editing capabilities is also not missed and text coloring is also not missed.
    Or you can set all fields to input fields and set the read only/edit property based on the condition and set the cell design of the fields accordingly, so that the users can distinguish easily.
    Regards,
    Harsha

  • Stored procedure in purchase order for duplicate item for a vendor

    Hi all
    I have written a stored procedure for duplicate item for vendor the output i need from this SP is whenever for a vendor we will raise purchase order the system should check that their shouldn't be any po in the system for the same item by the selected vendor. Its working fine when only one item is selected but it is behaving wrongly when more than one item is selected.
    If (@object_type='22' and @transaction_type='A')
    BEGIN
    Declare @Vend as varchar(200)
    Declare @ItemCode as varchar(200)
    Select @Vend =CardCode From OPOR Where DocEntry = @list_of_cols_val_tab_del
    Select @ItemCode=ItemCode From POR1 Where DocEntry=@list_of_cols_val_tab_del
    IF 1 !=(Select Count(T0.DocEntry) From OPOR T0  Inner Join POR1 T1 On T0.DocEntry=T1.DocEntry  Where T0.CardCode=@Vend and T1.ItemCode=@ItemCode)
    Begin
    select @error =1
    select @error_message = 'Item Code Already Exists For This Vendor'
    end
    end
    Thanks
    Rashid.

    Hi Rashid,
    Try this,
    if @object_type = N'22' and @transaction_type in (N'A', N'U')
    begin
    declare @line1 int
    declare @lin1 int
    declare @out1 int
    Set @out1 = 0
    SET @lin1 = 0
    Declare @Vend as varchar(200)
    Declare @ItemCode as varchar(200)
    Select @Vend = CardCode From OPOR Where DocEntry = @list_of_cols_val_tab_del
    Select @line1 = Max (LineNum)FROM POR1 WHERE POR1.DocEntry = @list_of_cols_val_tab_del
    While @lin1 < @line1
    Begin
         Select @ItemCode=ItemCode From POR1 Where DocEntry=@list_of_cols_val_tab_del and LineNum = @lin1
          if (SELECT COUNT(T0.DocEntry) FROM POR1 T0 inner join OPOR T1 on T0.DocEntry = T1.DocEntry
          WHERE T0.ItemCode = @ItemCode and T1.CardCode = @Vend)> 1
          Begin
               Set @Out1 = 1
               Break;
          END
               Else
               Begin
               Set @lin1 = @lin1+1
               Continue
          END
    END
    Set @lin1 = @lin1 + 1
    if @out1 = 1
    begin
          Set @error = 1
          Set @error_message = 'Item Code in line ' + CONVERT(nvarchar(4), @lin1) + N'already Exists For This Vendor!'
    End
    END
    Regards,
    Bala

  • Urgency Restrict No. of session for any particular user

    Hi All.
    Can we restrict any particular user no of session that if his nos. of session exceeded from 3 then all of his session should be killed.

    Thanks for reply.
    Currently I have a default profile for all users and resources of this profile are as follows:
    Resource Name Type Limit
    COMPOSITE_LIMIT     KERNEL     UNLIMITED
    FAILED_LOGIN_ATTEMPTS     PASSWORD     UNLIMITED
    SESSIONS_PER_USER     KERNEL     UNLIMITED
    PASSWORD_LIFE_TIME     PASSWORD     UNLIMITED
    CPU_PER_SESSION     KERNEL     UNLIMITED
    PASSWORD_REUSE_TIME     PASSWORD     UNLIMITED
    CPU_PER_CALL     KERNEL     UNLIMITED
    PASSWORD_REUSE_MAX     PASSWORD     UNLIMITED
    LOGICAL_READS_PER_SESSION KERNEL     UNLIMITED
    PASSWORD_VERIFY_FUNCTION PASSWORD     NULL
    LOGICAL_READS_PER_CALL     KERNEL     UNLIMITED
    PASSWORD_LOCK_TIME     PASSWORD     UNLIMITED
    IDLE_TIME     KERNEL     UNLIMITED
    PASSWORD_GRACE_TIME     PASSWORD     UNLIMITED
    CONNECT_TIME     KERNEL     UNLIMITED
    PRIVATE_SGA     KERNEL     UNLIMITED
    resource_limit parameter in initprod.ora file is set to FALSE.
    Now first of all I need to alter resource_limit paratmeter to TRUE with scope=both.
    Then need to create a new profile and define sessions_per_user 3.
    My question is that whether I have to define all default profile resources in the new profile or not?
    Do I need to grant create_session priviliges to every user after assigning new profile?
    Can I assign both profile to a single user?
    Brgs.
    Hassan

  • How to check mass change(vendor) done by any particular user .

    Hi,
    What is a transaction used  to check mass change(vendor) done by any particular user .
    Thanks,
    Dharmesh

    HI
    pls try this table CDHDR
    Thanks & Regards
    Phaneendra

  • Running total for duplicate rows

    Hi,
    I am trying to write an sql which shows the running total for records which has duplicate. Please share any idea to get this.
    sample rows:
    col1 col2 col3
    1      A    2
    1      A    2
    1      A    2
    1      B    3
    1      B    3
    1      C    5
    1      D    2
    1      D    2o/p required:
    col1 col2 col3  cumulative_tot
    1      A    2       2
    1      A    2       2
    1      A    2       2
    1      B    3       5
    1      B    3       5
    1      C    5       10
    1      D    2       12
    1      D    2       12

    Hi,
    Try this:
    WITH A AS
    select 1 col1,  'A' col2, 2 col3  from dual union all
    select 1 col1,  'A' col2, 2 col3  from dual union all
    select 1 col1,  'A' col2, 2 col3  from dual union all
    select 1 col1,  'B' col2, 3 col3  from dual union all
    select 1 col1,  'B' col2, 3 col3  from dual union all
    select 1 col1,  'C' col2, 5 col3  from dual union all
    select 1 col1,  'D' col2, 2 col3  from dual union all
    select 1 col1,  'D' col2, 2 col3  from dual
    ,B AS
    SELECT
      A.*
      ,ROW_NUMBER() OVER (PARTITION BY COL1, COL2 ORDER BY 1) RN
    FROM
      A
    SELECT
      B.*
      ,SUM(CASE WHEN RN = 1 THEN COL3 ELSE 0 END) OVER ( ORDER BY COL1, COL2 ,RN ) cumulative_tot
    FROM
      B
    COL1 COL2 COL3 RN CUMULATIVE_TOT
       1 A       2  1              2
       1 A       2  2              2
       1 A       2  3              2
       1 B       3  1              5
       1 B       3  2              5
       1 C       5  1             10
       1 D       2  1             12
       1 D       2  2             12
    8 rows selected Regards,
    Peter

  • Enable hide/show only for selected rows for table in table

    I have an advanced table with a detail table connected by a view link. This adds a "Details" column of Hide/Show links on the left of the table to expand the inner-table for each row of the outer-table. The goal is to have the hide/show in the outer table, only when there is data for the outer row in the detail region.
    Normally, hide/show appears for all rows in the outer table.
    Thanks!

    In the processRequest method of the controller execute the query of the Outer table region and check is there any row or not.
    If yes then do nothing else hide the bean i.e. hide/show bean. You need to do PPR for this.
    Thanks
    --Anil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • SQL Plus: Check for duplicate rows

    Hi.
    Let say I have a table called HISTORY.
    I have 3 fields in this table(EQ_NO, HISTORY_TYPE, REC_TIME_IN)
    Sample data:
    ABC123,REC,12:05
    ABC123,STA,12:05
    ABC123,DIS,12:00
    XYZ123,REC,12:05
    XYZ123,STA,12:05
    XYZ123,DIS,11:00
    Question:
    How to select the data where its REC_TIME_IN is/are not equal to same EQ_NO and HISTORY_TYPE = 'REC') ??
    Thanks.

    If I understood well, if the data be like this :
    ABC123,REC,12:05
    ABC123,REC,13:05
    ABC123,STA,12:05
    ABC123,STA,12:05
    ABC123,DIS,12:00
    XYZ123,REC,10:05
    XYZ123,REC,12:05
    XYZ123,STA,12:05
    XYZ123,DIS,11:00
    The query result should be :
    ABC123,REC,12:05
    ABC123,REC,13:05
    XYZ123,REC,10:05
    XYZ123,REC,12:05
    If so :
    create table test(
    EQ_NO varchar2(10),
    HISTORY_TYPE char(3),
    REC_TIME_IN varchar(10))
    insert into test values('ABC123','REC','12:05' );
    insert into test values('ABC123','REC','13:05' );
    insert into test values('ABC123','STA','12:05' );
    insert into test values('ABC123','STA','12:05' );
    insert into test values('ABC123','DST','12:00' );
    insert into test values('XYZ123','REC','10:05' );
    insert into test values('XYZ123','REC','12:05' );
    insert into test values('XYZ123','STA','12:05' );
    insert into test values('XYZ123','DIS','11:05' );
    select a.*
    from test a
    where eq_no||history_type
    in (select eq_no||history_type
    from test b
    where a.rec_time_in = b.rec_time_in )
    AND history_type = 'REC'

  • Need help with a SQL qurey that returns multiple rows for one record?

    I have the following query where I use a CASE WHEN clause to determine the date of a shift that begins with "FRLO" on day1 - day14 of the pay period. It works great if a schedule record contains one day that begins "FRLO", but if more than one day is "FRLO" then it only returns the first day it finds and not the others. Is there some way to get the query to return a ron for every day 1 - 14 that begins "FRLO"? System if Oracle 11G
    Order of the results is not important as this is part of a larger query that orders the results.
    Thanks in advance for any help,
    George
    SELECT s.empid,
    CASE
    WHEN UPPER (SUBSTR (s.Day1, 0, 4)) = 'FRLO'
    THEN
    pp.startpp
    WHEN UPPER (SUBSTR (s.Day2, 0, 4)) = 'FRLO'
    THEN
    pp.startpp + 1
    WHEN UPPER (SUBSTR (s.Day3, 0, 4)) = 'FRLO'
    THEN
    pp.startpp + 2
    WHEN UPPER (SUBSTR (s.Day4, 0, 4)) = 'FRLO'
    THEN
    pp.startpp + 3
    WHEN UPPER (SUBSTR (s.Day5, 0, 4)) = 'FRLO'
    THEN
    pp.startpp + 4
    WHEN UPPER (SUBSTR (s.Day6, 0, 4)) = 'FRLO'
    THEN
    pp.startpp + 5
    WHEN UPPER (SUBSTR (s.Day7, 0, 4)) = 'FRLO'
    THEN
    pp.startpp + 6
    WHEN UPPER (SUBSTR (s.Day8, 0, 4)) = 'FRLO'
    THEN
    pp.startpp + 7
    WHEN UPPER (SUBSTR (s.Day9, 0, 4)) = 'FRLO'
    THEN
    pp.startpp + 8
    WHEN UPPER (SUBSTR (s.Day10, 0, 4)) = 'FRLO'
    THEN
    pp.startpp + 9
    WHEN UPPER (SUBSTR (s.Day11, 0, 4)) = 'FRLO'
    THEN
    pp.startpp + 10
    WHEN UPPER (SUBSTR (s.Day12, 0, 4)) = 'FRLO'
    THEN
    pp.startpp + 11
    WHEN UPPER (SUBSTR (s.Day13, 0, 4)) = 'FRLO'
    THEN
    pp.startpp + 12
    WHEN UPPER (SUBSTR (s.Day14, 0, 4)) = 'FRLO'
    THEN
    pp.startpp + 13
    END
    startdate,
    NULL starttime,
    NULL endtime,
    8 hours,
    0 minutes
    FROM schedules s
    JOIN
    payperiods pp
    ON pp.periodid = s.periodid
    WHERE UPPER (SUBSTR (s.Day1, 0, 4)) = 'FRLO'
    OR UPPER (SUBSTR (s.Day2, 0, 4)) = 'FRLO'
    OR UPPER (SUBSTR (s.Day3, 0, 4)) = 'FRLO'
    OR UPPER (SUBSTR (s.Day4, 0, 4)) = 'FRLO'
    OR UPPER (SUBSTR (s.Day5, 0, 4)) = 'FRLO'
    OR UPPER (SUBSTR (s.Day6, 0, 4)) = 'FRLO'
    OR UPPER (SUBSTR (s.Day7, 0, 4)) = 'FRLO'
    OR UPPER (SUBSTR (s.Day8, 0, 4)) = 'FRLO'
    OR UPPER (SUBSTR (s.Day9, 0, 4)) = 'FRLO'
    OR UPPER (SUBSTR (s.Day10, 0, 4)) = 'FRLO'
    OR UPPER (SUBSTR (s.Day11, 0, 4)) = 'FRLO'
    OR UPPER (SUBSTR (s.Day12, 0, 4)) = 'FRLO'
    OR UPPER (SUBSTR (s.Day13, 0, 4)) = 'FRLO'
    OR UPPER (SUBSTR (s.Day14, 0, 4)) = 'FRLO';
    CURRENT OUTPUT
    EMPID STARTDATE STARTTIME ENDTIME HOURS MINUTES
    753738, 3/25/2013 , , ,8 ,0
    753740, 3/25/2013 , , ,8 ,0
    753748, 3/25/2013 , , ,8 ,0
    DESIRED OUTPUT
    EMPID STARTDATE STARTTIME ENDTIME HOURS MINUTES
    753738, 3/25/2013 , , ,8 ,0
    753740, 3/25/2013 , , ,8 ,0
    753748, 3/25/2013 , , ,8 ,0
    753738, 3/26/2013 , , ,8 ,0
    753740, 3/26/2013 , , ,8 ,0
    753740, 3/28/2013 , , ,8 ,0
    753748, 1/1/2013 , , ,8 ,0
    753738, 4/3/2013 , , ,8 ,0
    753748, 4/3/2013 , , ,8 ,0
    CREATE TABLE SCHEDULES
    SCHEDULEID NUMBER(12) NOT NULL,
    EMPID NUMBER(12) NOT NULL,
    PERIODID VARCHAR2(6 BYTE) NOT NULL,
    AREAID NUMBER(12) NOT NULL,
    DAY1 VARCHAR2(50 BYTE),
    DAY2 VARCHAR2(50 BYTE),
    DAY3 VARCHAR2(50 BYTE),
    DAY4 VARCHAR2(50 BYTE),
    DAY5 VARCHAR2(50 BYTE),
    DAY6 VARCHAR2(50 BYTE),
    DAY7 VARCHAR2(50 BYTE),
    DAY8 VARCHAR2(50 BYTE),
    DAY9 VARCHAR2(50 BYTE),
    DAY10 VARCHAR2(50 BYTE),
    DAY11 VARCHAR2(50 BYTE),
    DAY12 VARCHAR2(50 BYTE),
    DAY13 VARCHAR2(50 BYTE),
    DAY14 VARCHAR2(50 BYTE),
    NOPTIND1 INTEGER DEFAULT 0,
    NOPTIND2 INTEGER DEFAULT 0,
    NOPTIND3 INTEGER DEFAULT 0,
    NOPTIND4 INTEGER DEFAULT 0,
    NOPTIND5 INTEGER DEFAULT 0,
    NOPTIND6 INTEGER DEFAULT 0,
    NOPTIND7 INTEGER DEFAULT 0,
    NOPTIND8 INTEGER DEFAULT 0,
    NOPTIND9 INTEGER DEFAULT 0,
    NOPTIND10 INTEGER DEFAULT 0,
    NOPTIND11 INTEGER DEFAULT 0,
    NOPTIND12 INTEGER DEFAULT 0,
    NOPTIND13 INTEGER DEFAULT 0,
    NOPTIND14 INTEGER DEFAULT 0
    CREATE TABLE PAYPERIODS
    PERIODID VARCHAR2(6 BYTE) NOT NULL,
    STARTPP DATE,
    ENDPP DATE
    Insert into SCHEDULES
    (SCHEDULEID, EMPID, PERIODID, AREAID, DAY1,
    DAY2, DAY3, DAY4, DAY5, DAY6,
    DAY7, DAY8, DAY9, DAY10, DAY11,
    DAY12, DAY13, DAY14, NOPTIND1, NOPTIND2,
    NOPTIND3, NOPTIND4, NOPTIND5, NOPTIND6, NOPTIND7,
    NOPTIND8, NOPTIND9, NOPTIND10, NOPTIND11, NOPTIND12,
    NOPTIND13, NOPTIND14)
    Values
    (3693744, 753738, '082013', 2167, 'X',
    'FRLO<1530>', 'FRLO<1530>', '1530', '1530', '1530',
    'X', 'X', '1530', '1530', 'FRLO',
    '1530', '1530', 'X', 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0);
    Insert into SCHEDULES
    (SCHEDULEID, EMPID, PERIODID, AREAID, DAY1,
    DAY2, DAY3, DAY4, DAY5, DAY6,
    DAY7, DAY8, DAY9, DAY10, DAY11,
    DAY12, DAY13, DAY14, NOPTIND1, NOPTIND2,
    NOPTIND3, NOPTIND4, NOPTIND5, NOPTIND6, NOPTIND7,
    NOPTIND8, NOPTIND9, NOPTIND10, NOPTIND11, NOPTIND12,
    NOPTIND13, NOPTIND14)
    Values
    (3693745, 753740, '082013', 2167, 'X',
    'FRLO<1530>', 'FRLO<1530>', '1530', 'FRLO', '1530',
    'X', 'X', '1530', '1530', '1530',
    '1530', '1530', 'X', 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0);
    Insert into SCHEDULES
    (SCHEDULEID, EMPID, PERIODID, AREAID, DAY1,
    DAY2, DAY3, DAY4, DAY5, DAY6,
    DAY7, DAY8, DAY9, DAY10, DAY11,
    DAY12, DAY13, DAY14, NOPTIND1, NOPTIND2,
    NOPTIND3, NOPTIND4, NOPTIND5, NOPTIND6, NOPTIND7,
    NOPTIND8, NOPTIND9, NOPTIND10, NOPTIND11, NOPTIND12,
    NOPTIND13, NOPTIND14)
    Values
    (3693746, 753748, '082013', 2167, 'X',
    'FRLO<1530>', '1530', '1530', '1530', '1530',
    'X', 'X', 'FRLO<1530>', '1530', 'FRLO',
    '1530', '1530', 'X', 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0);
    COMMIT;
    Insert into PAYPERIODS
    (PERIODID, STARTPP)
    Values
    ('082013', TO_DATE('03/24/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    COMMIT;

    Do you have the opportunity to change the data model to have one day per row ? It would make this easier to get this result without the need for a 14-way CASE or UNION.
    If not...
    The case statement will return as soon as it matches one of the conditions. Since you want a match when any column in the row starts with FRLO you can use a UNION ALL treating each column as a separate result. There may be more efficient ways to do this, but here is one way:
    Select S.Empid,       Pp.Startpp Startdate,       Null Starttime,       Null Endtime,       8 Hours,       0 Minutes
      From Schedules S       Join  Payperiods Pp On Pp.Periodid = S.Periodid
      Where Upper (Substr (S.Day1, 0, 4)) = 'FRLO'
    Union All 
    Select S.Empid,       Pp.Startpp+1 Startdate,       Null Starttime,       Null Endtime,       8 Hours,       0 Minutes
      From Schedules S       Join  Payperiods Pp On Pp.Periodid = S.Periodid
      Where Upper (Substr (S.Day2, 0, 4)) = 'FRLO'
    Union All 
    Select S.Empid,       Pp.Startpp+2 Startdate,       Null Starttime,       Null Endtime,       8 Hours,       0 Minutes
      From Schedules S       Join  Payperiods Pp On Pp.Periodid = S.Periodid
      Where Upper (Substr (S.Day3, 0, 4)) = 'FRLO'
    Union All 
    Select S.Empid,       Pp.Startpp+3 Startdate,       Null Starttime,       Null Endtime,       8 Hours,       0 Minutes
      From Schedules S       Join  Payperiods Pp On Pp.Periodid = S.Periodid
      Where Upper (Substr (S.Day4, 0, 4)) = 'FRLO'
    Union All 
    Select S.Empid,       Pp.Startpp+4 Startdate,       Null Starttime,       Null Endtime,       8 Hours,       0 Minutes
      From Schedules S       Join  Payperiods Pp On Pp.Periodid = S.Periodid
      Where Upper (Substr (S.Day5, 0, 4)) = 'FRLO'
    Union All 
    Select S.Empid,       Pp.Startpp+5 Startdate,       Null Starttime,       Null Endtime,       8 Hours,       0 Minutes
      From Schedules S       Join  Payperiods Pp On Pp.Periodid = S.Periodid
      Where Upper (Substr (S.Day6, 0, 4)) = 'FRLO'
    Union All 
    Select S.Empid,       Pp.Startpp+6 Startdate,       Null Starttime,       Null Endtime,       8 Hours,       0 Minutes
      From Schedules S       Join  Payperiods Pp On Pp.Periodid = S.Periodid
      Where Upper (Substr (S.Day7, 0, 4)) = 'FRLO'
    Union All 
    Select S.Empid,       Pp.Startpp+7 Startdate,       Null Starttime,       Null Endtime,       8 Hours,       0 Minutes
      From Schedules S       Join  Payperiods Pp On Pp.Periodid = S.Periodid
      Where Upper (Substr (S.Day8, 0, 4)) = 'FRLO'
    Union All 
    Select S.Empid,       Pp.Startpp+8 Startdate,       Null Starttime,       Null Endtime,       8 Hours,       0 Minutes
      From Schedules S       Join  Payperiods Pp On Pp.Periodid = S.Periodid
      Where Upper (Substr (S.Day9, 0, 4)) = 'FRLO'
    Union All 
    Select S.Empid,       Pp.Startpp+9 Startdate,       Null Starttime,       Null Endtime,       8 Hours,       0 Minutes
      From Schedules S       Join  Payperiods Pp On Pp.Periodid = S.Periodid
      Where Upper (Substr (S.Day10, 0, 4)) = 'FRLO'
    Union All 
    Select S.Empid,       Pp.Startpp+10 Startdate,       Null Starttime,       Null Endtime,       8 Hours,       0 Minutes
      From Schedules S       Join  Payperiods Pp On Pp.Periodid = S.Periodid
      Where Upper (Substr (S.Day11, 0, 4)) = 'FRLO'
    Union All 
    Select S.Empid,       Pp.Startpp+11 Startdate,       Null Starttime,       Null Endtime,       8 Hours,       0 Minutes
      From Schedules S       Join  Payperiods Pp On Pp.Periodid = S.Periodid
      Where Upper (Substr (S.Day12, 0, 4)) = 'FRLO'
    Union All 
    Select S.Empid,       Pp.Startpp+12 Startdate,       Null Starttime,       Null Endtime,       8 Hours,       0 Minutes
      From Schedules S       Join  Payperiods Pp On Pp.Periodid = S.Periodid
      Where Upper (Substr (S.Day13, 0, 4)) = 'FRLO'
    Union All 
    Select S.Empid,       Pp.Startpp+13 Startdate,       Null Starttime,       Null Endtime,       8 Hours,       0 Minutes
      From Schedules S       Join  Payperiods Pp On Pp.Periodid = S.Periodid
      Where Upper (Substr (S.Day14, 0, 4)) = 'FRLO'

  • Sql delete command

    I have one table emp, here emp having 3 fields, names like empno,ename,job.
    SQL> select *From emp;
    EMPNO ENAME JOB
    23 SEKHAR JAVA
    34 RAVI DBA
    12 ramesh testing
    I want to delete empno column and job column do not use rowid,fields.
    I want output like this
    SQL> select *From emp;
    EMPNO ENAME JOB
    kumar
    ravi
    raja
    karhtik
    send me command.
    thanks in advance.

    Hi,
    By using unused command you can delate the specific column either logically and physically.
    Logically drop the unused columns:-
    ALTER TABLE table_name SET UNUSED (column_name);
    ALTER TABLE table_name SET UNUSED (column_name1, column_name2);
    Physically drop the unused columns:-
    ALTER TABLE table_name DROP UNUSED COLUMNS;
    ALTER TABLE table_name DROP COLUMN column_name;
    ALTER TABLE table_name DROP (column_name1, column_name2);
    I think its helpful to you.
    Regards,
    Narendra G.

  • Sql delete record where duplicate in part of raw

    in sql table  i need to delete all record where the time between it  1 or 2 minute or the same and must be the same id but keep the firest record
        ID             Time                            SN   SD   WE   
    FW
        10    2014-06-30 19:17:37.000    I    0    100    0
        10    2014-06-30 19:17:42.000    I    0    100    0
        10    2014-06-30 19:17:46.000    I    0    100    0
        10    2014-06-30 19:17:58.000    I    0    100    0
        10    2014-06-30 20:37:46.000    I    0    100    0
    or
         ID             Time                            SN   SD   WE   
    FW
        10    2014-07-01 21:10:33.000    I    0    100    0
        10    2014-07-01 21:11:06.000    O    0    100    0
        10    2014-07-02 20:53:36.000    I    0    100    0
        10    2014-07-02 20:53:38.000    I    0    100    0
        10    2014-07-02 20:54:33.000    O    0    100    0
        10    2014-07-02 20:54:41.000    O    0    100    0
        10    2014-07-02 20:55:22.000    o    0    100    0
    to be
        ID             Time                            SN   SD   WE   
    FW
        10    2014-06-30 19:17:37.000    I    0    100    0
        10    2014-06-30 20:37:46.000    I    0    100    0
    and
        ID             Time                            SN   SD   WE   
    FW
        10    2014-07-01 21:10:33.000    I    0    100    0
        10    2014-07-02 20:53:36.000    I    0    100    0

    i think this
    SELECT *
    --DELETE t
    FROM NEWFP.dbo.CHECKINOUT t
    WHERE EXISTS (
    SELECT 1
    FROM NEWFP.dbo.CHECKINOUT
    WHERE USERID = t.USERID
    AND CHECKTIME < t.CHECKTIME
    AND CHECKTIME >= DATEADD(minute,-5,t.CHECKTIME)
    Once you're happy that it gives you the required records just comment the SELECT *, uncomment the DELETE part and execute
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • ISight not working for non-Apple apps under particular user account

    I noticed that my iSight built into Macbook Pro 15" is not working anymore for non-Apple apps (Skype and Webex at least) and working for Facetime and Messages Beta under same account.
    I tried to test it using different account on OS X with Skype and it is working great!
    I'm using 10.7.3.
    Any advice?

    Hi,
    I take it that in System Information the camera is listed under USB items ?
    Your speps say OS x 10.7.2
    Have you updated to OS X 10.7.3 ?
    If you have I would start with that by doing a COMBO Version (Not using Software Update)
    This will be everything that has been updated since OS X 107 came out and may catch those hard to trace issues.
    Using the FInder > Go Menu > Hold the ALT key and Select the Library that appears > then navigate to Preferences.
    In here find the Skype .plist.
    Open it with Quick Look.
    Can you capture that (Apple/CMD ( or ⌘) + Shift + 4 together (Also tap space bar at the end to get the Window) ) ? and post it here.
    I don't use Skype and don't have the .plist to see if it lists the camera.
    If it does it might pay to delete the.plist and force Skype to re-***** the hardware.  (It also depends how much of your other settings are in there)
    In the meantime if you go to the Skype Preferences can you see a Preview of the camera ?
    Can you turn Off access to the camera and turn it On again in Skype ?
    Skype does use Flash Player to do the Video.
    Is Webex a browser led thing that uses Flash ?
    If it looks like it is a Flash Issue do you have the GoogleTalk Video Plugin installed (there is a standalone and it is part of Chrome) ?
    9:08 PM      Saturday; February 18, 2012
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
      iMac 2.5Ghz 5i 2011 (Lion 10.7.3)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • Please help with an sql to show more than one records into single row for each student

    From the following data I would like to create an sql to get the information  as the following layout
    studentid,  firstTerm,  EnglishMark1,ScienceMark1,MathsMark1, Secondterm,EnglishMark2,ScienceMark2,MathsMark2,
    ThirdTerm,EnglishMark3,ScienceMark3,MathsMark3 // As single rows for each student
    Example
    1 First, 30,40,20,Sec,30,40,20,  simillarly next row for next row for another sudent. Please help to generate the sql for the same.
    Please help it would be very appreciate.
    With Thanks
    Pol
    polachan

    create table yourdata (studentid int, term varchar(10), section varchar(50), Mark int)
    insert into yourdata values
    (1,'First','Math',20),(1,'First','English',30),(1,'First','Science',40),
    (2,'First','Math',20),(2,'First','English',30),(2,'First','Science',40),
    (3,'First','Math',20),(3,'First','English',30),(3,'First','Science',40),
    (1,'Sec','Math',20),(1,'Sec','English',30),(1,'Sec','Science',40),
    (2,'Sec','Math',20),(2,'Sec','English',30),(2,'Sec','Science',40),
    (3,'Sec','Math',20),(3,'Sec','English',30),(3,'Sec','Science',40)
    Select studentid
    ,max(case when term='First' and section='English' Then Mark End) as EnglishMark1
    ,max(case when term='First' and section='Science' Then Mark End) as ScienceMark1
    ,max(case when term='First' and section='Math' Then Mark End) as MathMark1
    ,max(case when term='Sec' and section='English' Then Mark End) as EnglishMark2
    ,max(case when term='Sec' and section='Science' Then Mark End) as ScienceMark2
    ,max(case when term='Sec' and section='Math' Then Mark End) as MathMark2
    ,max(case when term='Third' and section='English' Then Mark End) as EnglishMark3
    ,max(case when term='Third' and section='Science' Then Mark End) as ScienceMark3
    ,max(case when term='Third' and section='Math' Then Mark End) as MathMark3
    From yourdata
    Group by studentid
    drop table yourdata

  • Deleting Duplicate Rows in a list

    Hey folks, I've scowered around a bit for the answer to this and can't for the life of my figure it out.
    I've got a list of ~2,000-3,000 words in the following format:
    Fact
    Fiction
    Funny
    Funny
    Funny
    Funky
    etc etc. I am looking to make numbers delete all the duplicate rows such that the above list would become:
    Fact
    Fiction
    Funny
    Funky
    All of these words are in column A on a separate sheet in a numbers document I'm using to run an experiment. Is there a built in command or something that would do this? (I'm a COMPLETE beginner at using Numbers as a heads up)
    Any help with this would be GREATLY appreciated.

    Teaghue wrote:
    Never mind! I found an old old post explaining that this can't be done in numbers, so I just did it in excel.
    Perfectly wrong !
    The way to achieve the described goal was described several times in this forum.
    *_You just didn't search carefully !_*
    Searching for delet AND duplicate return several threads.
    Here are two of them.
    I didn't made a typo. I used delet so that it retrieve delete as well as deleting
    http://discussions.apple.com/thread.jspa?messageID=12992492
    http://discussions.apple.com/thread.jspa?messageID=11559125
    Yvan KOENIG (VALLAURIS, France) mercredi 2 mars 2011 17:59:40

  • Duplicate records for Sale Order Cycle Report(excluding item level detail)

    I have posted this issue in number of forums but till today no one is able to answer it correctly.Here it is:
    I need to create a report which I think most of the sd consultants have also done it.It basically covers sales order cycle without item lvel detail such as:
    Sale Order No -- Sales Order Date-- Delivery No-- Delivery Date
    Now as we all know ,sales orders and deliveries are connected through item table which means in the output I will get duplicate rows for the report above.For Example, if a sales order share 3 items with the delivery then we will get 3 exact duplicate rows in the report.
    What can be the best solution?connecting through VBFA has alos same result as it also has item level details.
    I need a good solution.This a common report and there must be some solution

    Hiiii,
    It is standard SAP rule that system will catch the document flow (document link history) at item level.
    Now your problem that you dont want to show the line item based report because of duplicacy.
    Try this.
    Brows table VBFA -
    In screen selection select the following......
    1. Subsiquent document category
    2. Preceding item
    select "J" in Subsiquent document category
    and "000010" in Preceding item  then execute the table.
    Now system will not show multple line item based delivery report. so No duplicacy will be there
    Regards
    Shambhu Sarkar

Maybe you are looking for

  • Help using family sharing and separate apple id's

    My husband and I are currently using the same Apple ID and I would like to separate our devices by creating a new apple ID for one of us. What is the best way to do this? Will family sharing make this easier? I am not using family sharing currently.

  • Premiere Elements 8 Initial Impressions

    Premiere Elements 8 First Look: Part 1. Photoshop Elements 8 and Premiere Elements 8 are now installed on my Windows XP SP3 with about available 1 GB RAM and 70 GB free hard drive space and the virtual memory controlled by the operating system…not gr

  • I want to print an entire URL in the footer of a print page. How can I do this?

    I want the complete URL of a webpage to be printed in the footer section of the printout. When I have the URL printed in the far left footer section it gets cutoff by the center footer section which is cut off by the far right footer section.

  • After updating mountain lion it doesn't show mountain pic ?

    after updating when i check about this mac it doesn't show any Lion pic.. is this ok or i need to do something else..

  • Returns and replacement

    Hi Gurus, Kindly provide the information about the customer returns and replacement in respect of under warranty cases Eg Final product sold is gear box (based on BOM). If we received the gearbox from customer for repair we have to replace some parts