Results 1 to 7 of 7

Thread: Select unique columns from a record set

  1. #1
    Join Date
    Apr 2010
    Posts
    29

    Select unique columns from a record set

    Hello friends,

    I need you help to sort out my confusion which is related to some sql transaction. I have some large table, but from which I only want to display the unique columns. I don't know how to achieve this task. I have referred many sql books, but didn't get proper solution for this. If you know how to select only unique columns from table record set, then please let me know that. I am waiting for your reply.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Select unique columns from a record set

    I suggest you to use the 'DISTINCT' statement for to display unique column from the table. You need to sue this clause with select statement, and pass the column name that you want to display in the output. Below I have given the example of this 'DISTINCT', review it carefully:

    Select DISTINCT av1,av2,av3 From ABC

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Select unique columns from a record set

    According to me there are two ways to achieve this sql transaction. One of them is to use the 'unique' clause of the sql. And other is to make use of 'distinct' clause. There is quite small difference in between distinct and unique clause. But according to my knowledge the distinct' clause is best for this transaction.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Select unique columns from a record set

    The DISTINCT clause enables you to eliminate duplicates from the result set of sql table . But limitation of of this DISTINCT clause is that, it can only be used with select statements. If you want to know about it’s syntax then please see below:
    SELECT distinct columnNames
    FROM tableName
    WHERE predicates;

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Select unique columns from a record set

    Select lets you use the Distinct keyword to avoid duplicate rows from the table. Distinct keyword is very helpful in queries where we basically want to know if a value is available in a table and or not. Distinct itself can only be used only one time in a Select statement. However, you can stipulate more than one columns after Distinct.

  6. #6
    Join Date
    Sep 2005
    Posts
    1,434

    Re: Select unique columns from a record set

    You can use UNIQUE constraints to make sure that no duplicate values are entered in specific columns that do not participate in a primary key. Although both a UNIQUE constraint and a PRIMARY KEY constraint enforce uniqueness, use a UNIQUE constraint instead of a PRIMARY KEY constraint when you want to enforce the uniqueness of a column, or combination of columns, that is not the primary key.

  7. #7
    Join Date
    Apr 2010
    Posts
    29

    Re: Select unique columns from a record set

    Thanks friends for all your help. As per your above replies it seems that I need to use the 'Distinct' clause in the way to display only unique columns from a record set. I have also tried to use this keyword as per syntax mentioned in the above replies and it was successful. I am really appreciating all your help.

Similar Threads

  1. Select unique values using xsl
    By Elizabeth Allen in forum Software Development
    Replies: 6
    Last Post: 17-05-2010, 10:27 AM
  2. Select unique values without using distinct
    By Maya Angelou in forum Software Development
    Replies: 6
    Last Post: 17-05-2010, 10:26 AM
  3. Replies: 4
    Last Post: 14-05-2010, 12:16 AM
  4. Select unique records from a table
    By Conraad in forum Software Development
    Replies: 5
    Last Post: 13-05-2010, 12:01 AM
  5. SELECT UNIQUE and SELECT DISTINCT
    By TAARIQ in forum Software Development
    Replies: 3
    Last Post: 03-06-2009, 10:00 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,168,683.91869 seconds with 16 queries