当前位置: 动力学知识库 > 问答 > 编程问答 >

Oracle SQL Query for retrieving only 2 values among many values

问题描述:

I have a table as shown below:

amount debit credit

------ ----- ------

500 500

500 500

550 550

655 655

756 756

.

.

.

.

.

Now, the question is: How can I retrieve those duplicate values only in the Amount column to display in the screen without using the following:

IN (list)

or anything like this

网友答案:

You will need to supply the table name in this query

select amount, count(amount)
from table_name_here
group by amount
having count (amount) > 1;
网友答案:

You can use this query:

SELECT 
DISTINCT (AMOUNT)
FROM YOUR_TABLE_NAME;
网友答案:

The question is roughly understandable, so it seems you are looking for result from the following SQL:

SELECT AMOUNT
FROM TABLEX
GROUP BY AMOUNT
HAVING COUNT(AMOUNT) > 1;

I try to guess from your comment you are looking for result from below SQL:

SELECT 
  * 
FROM 
  TABLEX TBLX1,
 (
  SELECT 
    AMOUNT 
  FROM 
    TABLEX 
  GROUP BY 
    AMOUNT 
  HAVING COUNT(AMOUNT) > 1
 ) TBLX2
WHERE 
  TBLX1.AMOUNT = TBLX2.AMOUNT
分享给朋友:
您可能感兴趣的文章:
随机阅读: