开发者

SQL -Grab unique column combination from table

开发者 https://www.devze.com 2023-02-15 00:30 出处:网络
In Oracle, I have a table called \"MyTable\".This table has columns \'A\' and \'B\'.I want to find every unique combination of \'A\' and \'B\'.How would I do this?I\'d prefer to do this in SQL rather

In Oracle, I have a table called "MyTable". This table has columns 'A' and 'B'. I want to find every unique combination of 'A' and 'B'. How would I do this? I'd prefer to do this in SQL rather than PL/SQL.

Example:

Column A | Column B

开发者_StackOverflow中文版
Dog           Cat
Cat           Dog
Horse         Cat
Dog           Cat

A unique combination above should return 3 rows.

Thank You


select distinct columnA, columnB from table

or

select columnA, columnB from table
group by columnA, columnB


Do it like this:

Select A, B
From MyTable
Group by A, B
0

精彩评论

暂无评论...
验证码 换一张
取 消