Get unique values from Oracle SQL












0















I have a table data with have 100.000 rows+ and its content like below;



Service    Owner
ABC JOHN
ABC MARK
ABC MARK
ABC STEVE
ABC STEVE


The output what i want is like below. Only getting unique values for services;



Service     Owner
ABC JOHN
ABC MARK
ABC STEVE


How can i select the query?










share|improve this question

























  • Please explain your logic.

    – Gordon Linoff
    Nov 13 '18 at 19:03











  • I edited the question.

    – john true
    Nov 13 '18 at 19:05
















0















I have a table data with have 100.000 rows+ and its content like below;



Service    Owner
ABC JOHN
ABC MARK
ABC MARK
ABC STEVE
ABC STEVE


The output what i want is like below. Only getting unique values for services;



Service     Owner
ABC JOHN
ABC MARK
ABC STEVE


How can i select the query?










share|improve this question

























  • Please explain your logic.

    – Gordon Linoff
    Nov 13 '18 at 19:03











  • I edited the question.

    – john true
    Nov 13 '18 at 19:05














0












0








0








I have a table data with have 100.000 rows+ and its content like below;



Service    Owner
ABC JOHN
ABC MARK
ABC MARK
ABC STEVE
ABC STEVE


The output what i want is like below. Only getting unique values for services;



Service     Owner
ABC JOHN
ABC MARK
ABC STEVE


How can i select the query?










share|improve this question
















I have a table data with have 100.000 rows+ and its content like below;



Service    Owner
ABC JOHN
ABC MARK
ABC MARK
ABC STEVE
ABC STEVE


The output what i want is like below. Only getting unique values for services;



Service     Owner
ABC JOHN
ABC MARK
ABC STEVE


How can i select the query?







sql oracle






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 19:05







john true

















asked Nov 13 '18 at 19:03









john truejohn true

10211




10211













  • Please explain your logic.

    – Gordon Linoff
    Nov 13 '18 at 19:03











  • I edited the question.

    – john true
    Nov 13 '18 at 19:05



















  • Please explain your logic.

    – Gordon Linoff
    Nov 13 '18 at 19:03











  • I edited the question.

    – john true
    Nov 13 '18 at 19:05

















Please explain your logic.

– Gordon Linoff
Nov 13 '18 at 19:03





Please explain your logic.

– Gordon Linoff
Nov 13 '18 at 19:03













I edited the question.

– john true
Nov 13 '18 at 19:05





I edited the question.

– john true
Nov 13 '18 at 19:05












2 Answers
2






active

oldest

votes


















0














An aggregate query should do the trick:



SELECT   MIN(service), owner
FROM mytable
GROUP BY owner





share|improve this answer
























  • your answer and above answer gives me different rows count

    – john true
    Nov 13 '18 at 19:09











  • the other answer have more rows.

    – john true
    Nov 13 '18 at 19:18











  • This would work for the sample data and give the expected output. It sounds like you have rows where one owner has multiple services. If that is the case and you would like to see all unique services tied to the owner, you should go with the select distinct answer.

    – Patrick H
    Nov 13 '18 at 19:58



















0














Selecting the distinct service and owner will give you the unique combinations of service and owner.



SELECT DISTINCT service,owner FROM TABLE


Here's a SQLFiddle.






share|improve this answer


























  • Why? Help out by explaining -a bit- why does it solve OP's question

    – Alfabravo
    Nov 13 '18 at 19:06











  • @Alfabravo - Done!

    – dcp
    Nov 13 '18 at 19:08











  • your answer and below answer gives me different rows count.

    – john true
    Nov 13 '18 at 19:09











  • @john true - Added a SQLFiddle, which is producing the output you listed in your question.

    – dcp
    Nov 13 '18 at 19:17











  • @john what exactly is the correct row count?

    – Salman A
    Nov 13 '18 at 19:39











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53287867%2fget-unique-values-from-oracle-sql%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














An aggregate query should do the trick:



SELECT   MIN(service), owner
FROM mytable
GROUP BY owner





share|improve this answer
























  • your answer and above answer gives me different rows count

    – john true
    Nov 13 '18 at 19:09











  • the other answer have more rows.

    – john true
    Nov 13 '18 at 19:18











  • This would work for the sample data and give the expected output. It sounds like you have rows where one owner has multiple services. If that is the case and you would like to see all unique services tied to the owner, you should go with the select distinct answer.

    – Patrick H
    Nov 13 '18 at 19:58
















0














An aggregate query should do the trick:



SELECT   MIN(service), owner
FROM mytable
GROUP BY owner





share|improve this answer
























  • your answer and above answer gives me different rows count

    – john true
    Nov 13 '18 at 19:09











  • the other answer have more rows.

    – john true
    Nov 13 '18 at 19:18











  • This would work for the sample data and give the expected output. It sounds like you have rows where one owner has multiple services. If that is the case and you would like to see all unique services tied to the owner, you should go with the select distinct answer.

    – Patrick H
    Nov 13 '18 at 19:58














0












0








0







An aggregate query should do the trick:



SELECT   MIN(service), owner
FROM mytable
GROUP BY owner





share|improve this answer













An aggregate query should do the trick:



SELECT   MIN(service), owner
FROM mytable
GROUP BY owner






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 '18 at 19:06









MureinikMureinik

181k22131200




181k22131200













  • your answer and above answer gives me different rows count

    – john true
    Nov 13 '18 at 19:09











  • the other answer have more rows.

    – john true
    Nov 13 '18 at 19:18











  • This would work for the sample data and give the expected output. It sounds like you have rows where one owner has multiple services. If that is the case and you would like to see all unique services tied to the owner, you should go with the select distinct answer.

    – Patrick H
    Nov 13 '18 at 19:58



















  • your answer and above answer gives me different rows count

    – john true
    Nov 13 '18 at 19:09











  • the other answer have more rows.

    – john true
    Nov 13 '18 at 19:18











  • This would work for the sample data and give the expected output. It sounds like you have rows where one owner has multiple services. If that is the case and you would like to see all unique services tied to the owner, you should go with the select distinct answer.

    – Patrick H
    Nov 13 '18 at 19:58

















your answer and above answer gives me different rows count

– john true
Nov 13 '18 at 19:09





your answer and above answer gives me different rows count

– john true
Nov 13 '18 at 19:09













the other answer have more rows.

– john true
Nov 13 '18 at 19:18





the other answer have more rows.

– john true
Nov 13 '18 at 19:18













This would work for the sample data and give the expected output. It sounds like you have rows where one owner has multiple services. If that is the case and you would like to see all unique services tied to the owner, you should go with the select distinct answer.

– Patrick H
Nov 13 '18 at 19:58





This would work for the sample data and give the expected output. It sounds like you have rows where one owner has multiple services. If that is the case and you would like to see all unique services tied to the owner, you should go with the select distinct answer.

– Patrick H
Nov 13 '18 at 19:58













0














Selecting the distinct service and owner will give you the unique combinations of service and owner.



SELECT DISTINCT service,owner FROM TABLE


Here's a SQLFiddle.






share|improve this answer


























  • Why? Help out by explaining -a bit- why does it solve OP's question

    – Alfabravo
    Nov 13 '18 at 19:06











  • @Alfabravo - Done!

    – dcp
    Nov 13 '18 at 19:08











  • your answer and below answer gives me different rows count.

    – john true
    Nov 13 '18 at 19:09











  • @john true - Added a SQLFiddle, which is producing the output you listed in your question.

    – dcp
    Nov 13 '18 at 19:17











  • @john what exactly is the correct row count?

    – Salman A
    Nov 13 '18 at 19:39
















0














Selecting the distinct service and owner will give you the unique combinations of service and owner.



SELECT DISTINCT service,owner FROM TABLE


Here's a SQLFiddle.






share|improve this answer


























  • Why? Help out by explaining -a bit- why does it solve OP's question

    – Alfabravo
    Nov 13 '18 at 19:06











  • @Alfabravo - Done!

    – dcp
    Nov 13 '18 at 19:08











  • your answer and below answer gives me different rows count.

    – john true
    Nov 13 '18 at 19:09











  • @john true - Added a SQLFiddle, which is producing the output you listed in your question.

    – dcp
    Nov 13 '18 at 19:17











  • @john what exactly is the correct row count?

    – Salman A
    Nov 13 '18 at 19:39














0












0








0







Selecting the distinct service and owner will give you the unique combinations of service and owner.



SELECT DISTINCT service,owner FROM TABLE


Here's a SQLFiddle.






share|improve this answer















Selecting the distinct service and owner will give you the unique combinations of service and owner.



SELECT DISTINCT service,owner FROM TABLE


Here's a SQLFiddle.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 13 '18 at 19:17

























answered Nov 13 '18 at 19:06









dcpdcp

42.8k16119146




42.8k16119146













  • Why? Help out by explaining -a bit- why does it solve OP's question

    – Alfabravo
    Nov 13 '18 at 19:06











  • @Alfabravo - Done!

    – dcp
    Nov 13 '18 at 19:08











  • your answer and below answer gives me different rows count.

    – john true
    Nov 13 '18 at 19:09











  • @john true - Added a SQLFiddle, which is producing the output you listed in your question.

    – dcp
    Nov 13 '18 at 19:17











  • @john what exactly is the correct row count?

    – Salman A
    Nov 13 '18 at 19:39



















  • Why? Help out by explaining -a bit- why does it solve OP's question

    – Alfabravo
    Nov 13 '18 at 19:06











  • @Alfabravo - Done!

    – dcp
    Nov 13 '18 at 19:08











  • your answer and below answer gives me different rows count.

    – john true
    Nov 13 '18 at 19:09











  • @john true - Added a SQLFiddle, which is producing the output you listed in your question.

    – dcp
    Nov 13 '18 at 19:17











  • @john what exactly is the correct row count?

    – Salman A
    Nov 13 '18 at 19:39

















Why? Help out by explaining -a bit- why does it solve OP's question

– Alfabravo
Nov 13 '18 at 19:06





Why? Help out by explaining -a bit- why does it solve OP's question

– Alfabravo
Nov 13 '18 at 19:06













@Alfabravo - Done!

– dcp
Nov 13 '18 at 19:08





@Alfabravo - Done!

– dcp
Nov 13 '18 at 19:08













your answer and below answer gives me different rows count.

– john true
Nov 13 '18 at 19:09





your answer and below answer gives me different rows count.

– john true
Nov 13 '18 at 19:09













@john true - Added a SQLFiddle, which is producing the output you listed in your question.

– dcp
Nov 13 '18 at 19:17





@john true - Added a SQLFiddle, which is producing the output you listed in your question.

– dcp
Nov 13 '18 at 19:17













@john what exactly is the correct row count?

– Salman A
Nov 13 '18 at 19:39





@john what exactly is the correct row count?

– Salman A
Nov 13 '18 at 19:39


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53287867%2fget-unique-values-from-oracle-sql%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python