Using distinct on several columns

Dear all;
I am have a query of the following form
select distinct id, zoneid, close_date from table_one
which gave a different result
from the same query with a different form
select distinct close_date, id, zoneid from table_one
Hence, I would like to understand why and how the phrase distinct is being used when utilizied in several columns.
THank you

By all means, feel free to post a testcase that we can reproduce, along with your database version ( the result of: select * from v$version; ).
My gut feeling is that this has to do with your unknown data and unknown datatypes...or 'very maybe' your database version.
SQL> create table table_one as
  2  select 1 id, 1 zoneid, to_date('01-01-2010 22:22:22', 'dd-mm-yyyy hh24:mi:ss') close_date from
dual union
  3  select 1, 1 zoneid, to_date('01-01-2010 22:22:22', 'dd-mm-yyyy hh24:mi:ss') from dual union
  4  select 1, 1 zoneid, to_date('01-01-2010 22:22:23', 'dd-mm-yyyy hh24:mi:ss') from dual;
Table created.
SQL> select distinct id, zoneid, close_date from table_one;
        ID     ZONEID CLOSE_DATE
         1          1 01-01-2010 22:22:23
         1          1 01-01-2010 22:22:22
2 rows selected.
SQL> select distinct close_date, id, zoneid from table_one;
CLOSE_DATE                  ID     ZONEID
01-01-2010 22:22:23          1          1
01-01-2010 22:22:22          1          1
2 rows selected.Both outcomes are just as expected...

Similar Messages

  • Getting the count of DISTINCT of several columns

    How can i get the count of DISTINCT of several columns?
    SQL> select count(distinct ename) from emp;
    COUNT(DISTINCTENAME)
                      14
    SQL> select count(distinct ename, job) from emp;
    select count(distinct ename, job) from emp
    ERROR at line 1:
    ORA-00909: invalid number of arguments

    Hello,
    You should separate them out like this
    select count(distinct ename), count(distinct job) from emp;Regards

  • CE function to get distinct values from Column table

    Hi All,
    Could you please let me know the appropriate CE function to get the distinct values from column table.
    IT_WORK = SELECT DISTINCT AUFNR FROM :IT_WO_DETAILS;
    Thank you.

    Hi,
    If you have 10g, you can use Model( with model performance is better than connect by )
    Solution
    ========================================================================
    WITH t AS
    (SELECT '0989.726332, 1234.567432, 3453.736379, 3453.736379, 0989.726332, 3453.736379, 1234.567432, 1234.567432, 0989.726332'
    txt
    FROM DUAL)
    SELECT DISTINCT TRIM(CHAINE)
    FROM T
    MODEL
    RETURN UPDATED ROWS
    DIMENSION BY (0 POSITION)
    MEASURES (CAST( ' ' AS VARCHAR2(50)) AS CHAINE ,txt ,LENGTH(REGEXP_REPLACE(txt,'[^,]+',''))+1 NB_MOT)
    RULES
    (CHAINE[FOR POSITION FROM  1 TO NVL(NB_MOT[0],1) INCREMENT 1] =
    CASE WHEN NB_MOT[0] IS NULL THEN TXT[0] ELSE REGEXP_SUBSTR(txt[0],'[^,]+',1,CV(POSITION)) END );
    =========================================================================
    Demo
    =======================================================================
    SQL> WITH t AS
    2 (SELECT '0989.726332, 1234.567432, 3453.736379, 3453.736379, 0989.726332, 3453.736379, 123
    4.567432, 1234.567432, 0989.726332'
    3 txt
    4 FROM DUAL)
    5 SELECT DISTINCT TRIM(CHAINE)
    6 FROM T
    7 MODEL
    8 RETURN UPDATED ROWS
    9 DIMENSION BY (0 POSITION)
    10 MEASURES (CAST( ' ' AS VARCHAR2(50)) AS CHAINE ,txt ,LENGTH(REGEXP_REPLACE(txt,'[^,]+',''))+1 NB_MOT)
    11 RULES
    12 (CHAINE[FOR POSITION FROM  1 TO NVL(NB_MOT[0],1) INCREMENT 1] =
    13 CASE WHEN NB_MOT[0] IS NULL THEN TXT[0] ELSE REGEXP_SUBSTR(txt[0],'[^,]+',1,CV(POSITION)) END );
    TRIM(CHAINE)
    3453.736379
    1234.567432
    0989.726332
    SQL>
    ========================================================================

  • SSRS reporting with sharepoint list using Distinct and Multivalue parameters

    i want create ssrs report with sharepoint list using ms-vs(2008). i want create Distinct multivalue parameters by using CAML query. There is any way we put CAML query where we use Distinct keyword and IN clause in CAML query... i hope all experts will
    understand my poor English... sorry for poor English.. plz help me

    Hi AsifMehmood,
    Per my understanding you have create an SSRS report with SharePoint list, now you don’t know to create the distinct parameters by using CAML query,  right?
    For the CAML language doesn’t have any reserved word (or tag) to set this particular filter to remove duplicate results, but we can use the custom code to do this function. I have tested on my local environment and we can do that by create one hidden parameter(Param1)
    to get all the values from the fields which will  add the filter and then create another parameter(Param2) to get the distinct values based on the Param1, we use the custom code to do the deduplication.
    Step by Steps information in below thread for your reference to create the parameters and the custom code:
    "How to get distinct values of sharepoint column using SSRS"
    Other similar thread for your reference:
    https://audministrator.wordpress.com/2014/02/17/sharepoint-list-add-distinct-parameter-value/
    If your problem still exists, please feel free to ask and also try to provide us more details information.
    Regards
    Vicky Liu

  • Any way to export several columns from the Links panel?

    This was originally posted to the InDesign forum, was suggested there might be a script that could achieve this?
    Working on a textbook with hundreds of illustrations. Each Chapter has  up to 100.  Need to get several columns of data (file name and page #  that it appears on) exported from the Links Panel (in sorted order) so  they can be dropped into a spreadsheet. I am using TextWrangler which  will dump out all the filenames in a folder, but it sorts alphabetically  and I really want them sorted by the Page Numbers where they appear.

    This script creates a CSV file on the desktop that you can import in Excel. The file name is the same as the name of active indesign document.
    Kasyan
    var scriptName = "Generate list of links";
    if (app.documents.length == 0) ErrorExit("No documents are open. Please open a document and try again.");
    var page, allGraphics, graphic;
    var text = "File name;Page\r";
    var doc = app.activeDocument;
    for (var i = 0; i < doc.pages.length; i++) {
         page = doc.pages[i];
         allGraphics = page.allGraphics;
         for (var k = 0; k < allGraphics.length; k++) {
              graphic = allGraphics[k];
              if (graphic.itemLink != null) {
                   text += graphic.itemLink.name + ";" + page.name +"\r";
    WriteToFile(text);
    //-------------------------------------- FUNCTIONS ---------------------------------------------
    function WriteToFile(text) {
         var theFile = new File("~/Desktop/" + GetFileNameOnly(doc.name) + ".csv");
         theFile.open("w");
         theFile.write(text);
         theFile.close();
    function ErrorExit(error, icon) {
         alert(error, scriptName, icon);
         exit();
    function GetFileNameOnly(myFileName) {
         var myString = "";
         var myResult = myFileName.lastIndexOf(".");
         if (myResult == -1) {
              myString = myFileName;
         else {
              myString = myFileName.substr(0, myResult);
         return myString;

  • Using distinct and orderby in the select statment

    Hi All,
    Can anyone tell me what is the purpose of using distinct and orderby in the select statment.

    Hi,
    Using the distinct function with more than one column yields some substantial results. SQL will return the rows with distinct or unique combinations of those columns. Assume this same employee table has another column including the salary of each employee. With the use of the distinct function we can pull a list of unique job titles - salaries.
    SQL Code:
    SELECT DISTINCT job_titles, salary FROM employees;
    SQL has returned all the rows with unique combinations of job titles and salaries. Any duplicate combinations of job titles and salaries will be ignored. For example if we had two CEOs in the table making the same salary each year, only one row would be returned but if we had two CEOs with different salaries, both rows would be returned.
    Order by
    The SQL ORDER BY clause comes in handy when you want to sort your SQL result sets by some column(s). For example if you want to select all the persons from the already familiar Customers table and order the result by date of birth, you will use the following statement:
    SELECT * FROM Customers
    ORDER BY DOB
    As you can see the rows are sorted in ascending order by the DOB column, but what if you want to sort them in descending order? To do that you will have to add the DESC SQL keyword after your SQL ORDER BY clause:
    SELECT * FROM Customers
    ORDER BY DOB DESC
    If you don't specify how to order your rows, alphabetically or reverse, than the result set is ordered alphabetically, hence the following to SQL expressions produce the same result:
    SELECT * FROM Customers
    ORDER BY DOB
    SELECT * FROM Customers
    ORDER BY DOB ASC
    You can sort your result set by more than one column by specifying those columns in the SQL ORDER BY list. The following SQL expression will order by DOB and LastName:
    SELECT * FROM Customers
    ORDER BY DOB, LastName
    if its useful reward points

  • Bookmarks in several columns

    Is there a way to display bookmarks in several columns instead a one long ?
    Firefox 14.01 Win 7

    Have a look at this:
    *Multicolumn Bookmarks: https://addons.mozilla.org/firefox/addon/multicolumn-bookmarks/
    If it is your bookmark toolbar and you want multiple rows, look at this:
    *Multirow Bookmarks Toolbar Plus: https://addons.mozilla.org/firefox/addon/multirow-bookmarks-toolbarplus/
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''
    Not related to your question, but...
    You may need to update some plug-ins. Check your plug-ins and update as necessary:
    *Plug-in check --> http://www.mozilla.org/en-US/plugincheck/
    *Adobe Shockwave for Director Netscape plug-in: [https://support.mozilla.org/en-US/kb/Using%20the%20Shockwave%20plugin%20with%20Firefox#w_installing-shockwave Installing ('''''or Updating''''') the Shockwave plugin with Firefox]
    *'''''Adobe PDF Plug-In For Firefox and Netscape''''': [https://support.mozilla.org/en-US/kb/Using%20the%20Adobe%20Reader%20plugin%20with%20Firefox#w_installing-and-updating-adobe-reader Installing/Updating Adobe Reader in Firefox]
    *Shockwave Flash (Adobe Flash or Flash): [https://support.mozilla.org/en-US/kb/Managing%20the%20Flash%20plugin#w_updating-flash Updating Flash in Firefox]
    *Next Generation Java Plug-in for Mozilla browsers: [https://support.mozilla.org/en-US/kb/Using%20the%20Java%20plugin%20with%20Firefox#w_installing-or-updating-java Installing or Updating Java in Firefox]

  • I have a packardbell laptop with photoshop elements 8 installed from new. I have used it on several occasions but I cannot get it to run now.  When I open a photo using elements the Adobe box pops up saying that the programme has unexpectedley quit? can a

    I have a packardbell laptop with photoshop elements 8 installed from new. I have used it on several occasions but I cannot get it to run now.  When I open a photo using elements the Adobe box pops up saying that the programme has unexpectedley quit? can anyone help me please as I have several photos to edit before the end of this month. Many thanks for any help

    The "restore disk" is built into the Mac. See About Recovery.
    Need more specifics about what error messages you got while installing Adobe Flash.
    However, you can almost avoid Flash altogether by setting YouTube to play the HTML5 version instead.
    Click the Try something new! link at the bottom of the YouTube page.
    I don't know about the sound issue. Might be hardware as you think. Try other headphones to check.

  • From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    Hi,
    Use NVL or COALESCE:
    NVL (col_a, col_b)
    Returns col_a if col_a is not NULL; otherwise, it returns col_b.
    Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
    For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • I have not been able to use iTunes for several months.  Every time I open iTunes, it freezes by computer such that there is about a minutes between each action.  I am running iTunes 11 on Mac OS 10.6.8 and have a computer with maxed out memory.

    I have not been able to use iTunes for several months.  Every time I open iTunes, it freezes by computer such that there is about a minutes between each action.  I am running iTunes 11 on Mac OS 10.6.8 and have a computer with maxed out memory.  Help!  I can't access my iTunes content.

    I have not been able to use iTunes for several months.  Every time I open iTunes, it freezes by computer such that there is about a minutes between each action.  I am running iTunes 11 on Mac OS 10.6.8 and have a computer with maxed out memory.  Help!  I can't access my iTunes content.

  • There is no option to reject an incoming call in locked screen, there must be an icon on the screen for one who don't want to use lock button several times, i did'nt face this problem in last ios 6.1.3.

    There is no option to reject an incoming call in locked screen, there must be an icon on the screen for one who don't want to use lock button several times, i did'nt face this problem in last ios 6.1.3.

    A good read. Have you done anything at all to resolve your problem. Reset? Restore?
    By the way - "your products"... nobody here produced the iPhone, we are all just users. Apple is not here.

  • Execute immediate with using clause to pass column name dynamically

    Hai,
    Is there any way using execute immeidate to pass the column name dynamically. I used to pass the column value as dynamic with the help of "Using clause" . But if i use to pass column name, it is giving numberic error at run time. Eg,. for testing has been given below.
    1. Column value as dynamic, which is working correctly.
    create or replace function testexeimm (acctnum char)
    return number as
    acctbal number;
    begin
    execute immediate 'select balance from acct_master where acct_no=:a' into acctbal using acctnum;
    return acctbal;
    end;
    2. Column name as dynamic which is not working
    create or replace function testexeimm (colnam char)
    return char as
    acctbal char;
    begin
    execute immediate 'select :a from ch_acct_mast where rownum=1' into acctbal using colnam;
    return acctbal;
    end;
    Any help in this regard will be highly appericated.
    Regards
    Sridhar

    So the variable has to be numeric too:
    create or replace function testexeimm (colnam char)
    return number as
    acctbal number;
    begin
    execute immediate 'select '|||colnam||' from ch_acct_mast where rownum=1' into acctbal;
    return acctbal;
    end;Max
    http://oracleitalia.wordpress.com

  • I am using a Canon 640 printer and my MPNavigator will not remain open.  It pops open then quickly closes.  I've used it for several years but it just started doing this.  What can I do to fix this problem?

    I am using a Canon 640 printer and my MPNavigator will not remain open.  It pops open then quickly closes.  I've used it for several years but it just started doing this.  What can I do to fix this problem?

    I had a similar problem with a Canon MP800R under Mac OS X 10.9.2 Mavericks.
    In my case, the MP Navigator app in the dock was linking to the wrong file.
    It linked to Applications > MP Navigator 2.1.app > Contents > Resources > MP Navigator.app, but it should link to the "main" app, probably under Applications > MP Navigator 2.1.app.
    After pulling the correct MP Navigator app file to the dock, I can start MP Navigator again by clicking on it in the dock. However, when clicking on it, a second MP Navigator icon will show up in the dock and stay there until the app is closed. By the way, the MP800R scanner also works (although officially not supported by Canon).

  • Itunes was not installed correctly error 1114.  I have uninstalled and reinstalled using the steps several times., itunes was not installed correctly error 1114.  I have uninstalled and reinstalled using the steps several times.

    itunes was not installed correctly error 1114.  I have uninstalled and reinstalled using the steps several times., itunes was not installed correctly error 1114.  I have uninstalled and reinstalled using the steps several times.
    I have never been so close to packing the whole lot up and sending the ipad back!
    Please help!
    Kieran

    Issues installing iTunes or QuickTime for Windows
    iTunes 11.1.4 for Windows: Unable to install or open
    Troubleshooting issues with iTunes for Windows updates

  • SQL Data Sync - column type invalid for use as a key column

    Hello,
    our sync group is failing to do the sync. Here's a tracingID:
    For more information, provide tracing ID ‘e3e568b5-140a-4ae5-a4c8-c178c6bf805d’ to customer support.
    I must say, that the column in DB is not a PK or INDEX-ed, it was initially VARCHAR(MAX), after some reading I changed it to VARCHAR(200) and later to TEXT, but the result of syncing is still the same.
    Thank you,
    Bojan

    Hi Bojan,
    The error “column type invalid for use as a key column” could be due to the existence of unsupported data types or column properties when implementing the synchronization. I recommend you check your database according to this article:
    SQL Database Data Types supported by SQL Data Sync.
    Besides, before you design and implement a data synchronization plan, please check the following articles about system requirements for SQL Data Sync and so on.
    System Requirements for SQL Data Sync
    https://msdn.microsoft.com/en-us/library/azure/jj127278.aspx
    Known SQL Data Sync Limits
    https://msdn.microsoft.com/en-us/library/azure/jj590380.aspx
    SQL Data Sync Best Practices
    https://msdn.microsoft.com/en-us/library/azure/hh667328.aspx
    Thanks,
    Lydia Zhang
    Lydia Zhang
    TechNet Community Support

Maybe you are looking for

  • Some Apps not showing in the Apps page of iPhone

    Hi, I have an iPhone 4s with tonnes of apps on it. When synced with my computer in iTunes I can see a bunch of apps which I can sort by size etc and install and remove. Great. Except the list isn't complete. I seems like the newer apps I've downloade

  • HT1369 why wont my ipod shuffle sync with my laptop

    Help!

  • How can I see/change the assigned portlets for a page

    I have a need to identify what portlets will be shown on a portlet pages and adjust the groups. I find the tag setPortletsForUser in select_portlets.jsp but I can't find where it's is documented.

  • JDBC connection to SQL Server 2000 Service Pack 4

    Hello Everyone, I'm trying to do a simple application which save some values into a MS SQL Server 2000 Database's Table. The source code I've written is: package Logging; import com.brekeke.net.sip.sv.session.*; import com.brekeke.net.sip.sv.session.

  • Can't connect to datasource in em

    Hello, I configured JDBC datasource in Administration Console, then deployed it to the DB Adapter. In the porperty value of DataSourceName I filled in the jndi name "eis/DB/FeiYeConn". I didn't get any error report during the deployment, so I think m