How to return all rows with duplicate values? Inner join not working!

I have a 3 column table:
location (pk), name, size
I am attempting to select pairs of entries that have the same
name and size but different values for location (it is the
primary key.) My inner join does not seem to return what I need:
select a.location, a.name, a.size, b.location, b.name, b.size
from mytable a, mytable b where a.name = b.name and a.size =
b.size and a.location <> b.location;

One solution is like this:
SELECT dname, loc, deptno
FROM dept
WHERE (dname, loc) IN
(SELECT dname, loc
FROM dept
GROUP BY dname, loc
HAVING COUNT (*) > 1
ORDER BY dname, loc, deptno
Regards
Zlatko Sirotic

Similar Messages

  • How to return one ROW with Multiple value seperated by Colon in a SQL Query

    Hi,
    I have a SQL query as mentioned.
    select deptno
      from deptI want to mofidfy this query, so that this should return me department list with colon delimeted in one ROW.
    10:20:30:40.......Thanks,
    Deepak

    In 10g:
    select rtrim(xmlagg(xmlparse(content deptno || ':')).getstringval(), ':') data
    from   dept;
    DATA                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
    10:20:30:40with apologies for the abuse of XML...

  • Returning 250 rows with 1000 Values in "IN" Clause Oracle 10g On IBM AIX !!

    Hi,
    Recently we have done the OS migration of Oracle 10g Server from Windows Server to IBM AIX. Everything is fine, But today we came across one crucial bug in the code, i.e In the Select Query, though we're expecting 1000 rows with 1000 values in "IN" Clause , It's returning Only 250 rows. Where as it's returning 1000 rows in Windows Environment with 1000 values in "IN" Clause. I have browsed throgh Google for the resolution but failed to get that.
    This is something like,
    In Oracle 10g On windows :-
    select * from emp
    where dept_id in (1,2,3,...................1000);
    Assuming there  are the dept_id values in Emp table from 1 ... 1000, It's returning 1000 rows.
    In Oracle 10g On IBM AIX ,
    select * from emp
    where dept_id in (1,2,3,...................1000);
    Assuming there  are the dept_id values in Emp table from 1 ... 1000, It's returning 250 rows. Pls help me, what could be the reason for this. and what needs to be checked to fix this.
    Pls suggest !!!
    Raja

    mmmh. Did you compared the select count(*) from your_table; in the two cases.
    If the result is not good and nobody has deleted rows between migration and your test, you migration need to be replayed.
    Which migration did you select, Transportable database or exp/imp...?
    Edited by: Dba Z on 16 août 2009 08:56

  • Deleting  rows with missing values in field in start routine of update rule

    Hello experts,
    how can I delet rows with missing values in a specific field in the start routine of update rules?
    I think ABAP code should look something like this:
    delete ...  from DATA_PACKAGE where Z_NO = ''.
    thanks in advance for any suggestions!
    hiza

    Write:
    delete data_package where field = value.
    Hope it helps.
    Regards

  • Query to return ALL rows even those with zero counts

    Hi,
    The following query will return only those rows that have a non zero count value:
    select c.id, a.name, count(*) as XYZ from CON c, CUST a
    where c.help !='1' and (c.id = a.id) group by c.id, a.name order by c.id;
    The results are:
    1 ME 3
    3 YOU 4
    What i want is to return all rows in CUST and the count, XYZ, that correspond to each row in CUST that matches the whare condition above, even if the count is zero.
    ie
    1 ME 3
    2 WE 0
    3 YOU 4
    Can this be done?

    You may want to get the counts then do the outer join. If you simply count with an outer join you will get 1 for 'WE' because there is a row in the cust table with 'WE'. This may work for you;
    with
      cust as (
       select 1 id, 'ME' name from dual union all
       select 2 id, 'YOU' name from dual union all
       select 3 id, 'WE' name from dual),
      con as (
       select 1 id, '2' help from dual union all
       select 1 id, '2' help from dual union all
       select 1 id, '2' help from dual union all
       select 2 id, '2' help from dual union all
       select 2 id, '2' help from dual union all
       select 2 id, '2' help from dual union all
       select 2 id, '2' help from dual)
    -- end of test data 
    select a.id, a.name, nvl(c.cnt,0) xyz
    from cust a, 
       (select id, help, count(*) cnt
       from con
       where help !='1'
       group by id, help) c
    where a.id = c.id(+)

  • How to return all columns starting with E?

    How to return all columns starting with E in emp table?
    My attempts (below) were unsuccessful.
    SQL> SELECT E* from emp;
    SELECT E* from emp
    ERROR at line 1:
    ORA-00936: missing expression
    SQL> SELECT E.* FROM EMP;
    SELECT E.* FROM EMP
    ERROR at line 1:
    ORA-00904: "E": invalid identifier
    SQL> SELECT EMP.E* FROM EMP;
    SELECT EMP.E* FROM EMP
    ERROR at line 1:
    ORA-00936: missing expression

    You need to do it dynamically:
    SQL>  var cur refcursor
    SQL>  declare
      co varchar2(40);
    begin
      for c in (select column_name from cols where table_name = 'EMP' and column_name like 'E%') loop
        co := co || c.column_name || ',';
      end loop;
      open :cur for 'select '|| rtrim(co,',') || ' from emp';
    end;
    PL/SQL procedure successfully completed.
    SQL>  print cur
         EMPNO ENAME    
          7369 SMITH    
          7499 ALLEN    
          7521 WARD     
          7566 JONES    
          7654 MARTIN   
          7698 BLAKE    
          7782 CLARK    
          7788 SCOTT    
          7839 KING     
          7844 TURNER   
          7876 ADAMS    
          7900 JAMES    
          7902 FORD     
          7934 MILLER   
    14 rows selected.

  • How to get all rows/cols in pivot even if fact values are not available

    If I have a a result set and then pivot on it then only the side/top labels appear for items with fact values. Is there any way to achieve the following :
    Result Set gives the following pivot table
    Area1 Area3
    country 1 100 10
    country 3 200 20
    If there any way to ensure that pivot shows all row and column values and then fills in 0 for the missing facts ?
    ie.
    Area1 Area2 Area3
    Country1 100 0 10
    Country2 0 0 0
    Country3 200 0 20
    hope this makes sense. Basically I have a static format Excel report that the information is exported to and sometimes at the beginning of the month the daily report does not show all rows.
    Thanks
    Kevin

    outer join your dimensions to the facts so that all the dimensions are there

  • How to merge rows with similar values in alv grid display in webdynpro

    Hi experts,
                   i want to know about how to merge rows with similar values in alv grid display of webdynpro.grouping rows is possible in table display in webdynpro but i am not able to do row grouping in the alv grid display in webdynpro.
    kindly suggest.
    thanks ,
    Anita.

    Hi Anita,
    did you find a solution for this? I have opened a Thread, if you know the answer maybe you could help me out:
    Is there an ALV function similar to the TABLE Row grouping?
    Thanx in advanced!!!
    Kind Regards,
    Gerardo J

  • Tabular: Row filter on USERNAME() still returns all rows if current user is NOT matched in table??

    I have a table (basically the same setup in the various dynamic security in tabular blogs) where the table contains WindowsUserName stored as domain\username.
    I have a Row Filter on the table: SecurityTable has a filter of =SecurityTable[WindowsUserName]=USERNAME()
    When a user connects to the tabular model AND their name is matched in one of the rows they return JUST the rows with their match.  Which makes sense.
    However, if a user connects and their Windows user name is NOT in a row in that table....they return ALL rows???
    That makes no sense to me.
    It behaves almost as if it is doing a check and if it DOESN'T find a match it just returns all values.
    What am I missing?
    --------------EDIT-----------
    Found the issue: that use was (unknown to me) a domain admin, so... admin rights trump all :)

    Resolved:
    User had admin rights, didn't realize this at the time.

  • Show rows with empty values

    Hello,
    We are creating a cross tab report, with products as the columns, and relationship managers with direct and shared revenue displayed across the rows.
    For Eg
    Relationship Manager    Coverage         Product1   Product2   Product3   Product4
    Bob                                Direct                 100,           0,               35,            50
                                          Shared                0,              0,               15,            0
    Alex                               Direct                  15,            25,             40,            10
                                          Shared                5,              0,               5,               0
    George                          Direct                  0,               0,              0,               30
                                          Shared                0,               0,              0,               5
    The problem lies when either one of the products has no values, or one of the relationship managers has no direct or shared revenues. If one of the products has no revenues, it disappears, and also when one of the RMs has no direct or shared revenues, the Direct or Shared row disappears.
    I have tried to create a second query just included the Coverage variable, and using this variable in Query 2 with the RM variable from query 1, along with checking the "Show Rows with Empty Measure values", "Show Rows with Empty Dimension Values" and "Show when empty", but it still does not appear to work.
    It only shows rows with values in them, and shows the rows with empty values at the end with no RM.
    I have not tried to solve for empty columns yet.
    Help with this would be much appreciated!!!!!!!!
    Thank you

    Hi ,
    I think you can resolve this issue following ways ,
    you need create another query  ( Ex :Qauery2 ) add Product object and RM (Direct,shared) object only without  conation. So now query2 result wil have all product and RM(Direct,shared).
    Merge the Product object and RM  between query1 and query2
    Now create table using Product and RM from query2 and measure value from query1.  Now you will get row even there is no data.
    If you want try this sample report using efasion unvierse.
    1) Add year ,state and Discount objects  and apply condition Year Not in list "2004"  and state Not in list "California "
    2) run this query and create the cross tab table . Now you will not get 2004 column  and California row in table.
    3) Create query2 add Year and State only without any condition , run the query. Now query 2 will display all state and year .
    4) Merge the column Year and State between query1 and query2
    4) Create the cross table ussing Year and state from query2 and Discount from Query1
    Now cross table will show 2004 and California ,even there is not in query 1.
    I hope this will help you.
    Ponnarasu
    Edited by: ponnarasuk on Dec 7, 2011 12:48 PM

  • Updating multiple rows with different values

    Hi!
    I have a problem. I need to update more then 1000 rows with different values. How can I do it?
    For exsample i have table:
    id; color, date,
    1 red
    2 green
    3 white
    I need to update date field.
    Update table
    set date='01.02.03'
    where id=1
    Update table
    set date='01.03.03'
    where id=2
    Maybe there is way how to update multiple rows at one query?
    Sorry for my bad english.
    Thanks!

    Hi,
    You can try this
    UPDATE TABLE SET DATE = CASE
                        WHEN ID = 1 THEN TO_DATE('01-02-03','DD-MM-RR')
                        WHEN ID = 2 THEN TO_DATE('01-03-03','DD-MM-RR')
                        ENDcheers
    VT

  • How to return all fields when updating?

    When I update a lead, it only returns fields that are modified but not all fields in the XML.
    I noticed the LeadID and LeadFullname values are still being returned when updating which is good.
    How can I make it so it will return ALL fields that have values and not just the modified ones when updating?
    Thanks

    I have to query it after getting it back from the queue.

  • How to delete all mails with one klick?

    It's annoying to delete every single mail.
    How to delete all mails with one klick, like in the paperbasket?
    Thanks

    If the emails have been previously deleted (I.e. in the trash folder), tap Edit at the top of the list. You should see a delete all button at the bottom. If the messages are in a standard folder, they need to be handled one at a time.

  • How to get all rows in table to red using alternate rows properties option

    How to get all rows in table to red using alternate rows properties option

    Hi Khrisna,
    You can get all rows red by selecting the color red in the "Color" and "frequency" to 1 under the "Alternate Row/Column colors".
    I tried doing it and the colors freaked me out (all red) :-D
    Kindly tell me if im missing something.
    Regards,
    John Vincent

  • Apex 3.2 SVG Chart - How to plot Stacked Bar With Negative Values ?

    Currently Apex 3.2 Flash Chart (AnyChart 3.x) does not support Stacked bars with negative values.
    I try with SVG Stacked bars with positive values only, chart ploting works fine. When I add a new series with negative values (i.e -1) and I get a blank Chart region with no error.
    Based on this statement from Apex's documentation:
    *"AxisLine Indicates zero on charts that have negative values."*
    I appreciate your help on how to translate this statement into action ?
    (i.e how to override .Axisline class in CSS section ?)
    Thank you very much for your time.

    User614143,
    try to add the minumm negative value (but positive) to the parameter for the axis.
    e.g. show value+3000 (assuming -3000 is the minimum value)
    If you don't have a limitation for the negative values, it doesn't work. (or try to calculate first the most negative value in a before header process)
    hope this helps.
    Leo

Maybe you are looking for

  • No data in generated document/web service data source/complex response type

    I can define a report with a template with the BI Publisher server and the Template Builder Desktop plugin. When I use an sql statement as data source the preview functionality in Word and in the browser (logged in to the server) results in a correct

  • Multiple ID's on one computer

    Just bought a new iMac for our home office.  Can we set up multiple Apple ID's on one computer.  Do we each have our own itunes and app folders on the computer or do they get merged.

  • How do I determine what the problem is?

    In converting a word doc to pdf. the program runs for over 10 minutes or more then a note comes up saying a problem occurred that stopped conversion.  How do I determine the problem?

  • TDMS viewer not showing data with time stamp

    Need help with time stamping data in a TDMS file generated by DAQ Assistant. When I use the TDMS Viewer, with the x-scale set to absolute time, the date starts at 1903. If I use Excel to look at the file the start time is correct (i.e. 2013). Solved!

  • Gnome-Shell in Gnome 3.2 not working after upgrade

    Hi guys, after upgrading from Pacman, Gnome-Shell does not start up correctly. After login the Gnome-Keyring pops up (as usual) and after entering my password Gnome-Shell crashes ("oops.. something went wrong bla bla"). I could resolve this problem b