distinct partial column


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: distinct partial column

  1. #1
    Join Date
    Nov 2008
    Posts
    2

    distinct partial column

    Is it possible to select partial columns in sql?

    I have a table named MASTER

    for example
    it has 2 fields

    id address
    1 23-mvp
    2 34-yut
    3 33-yut
    4 12-mvt
    5 21-mvp


    I want to select Distinct part of the address field(ie distinct last 3 characters)

    result

    mvp
    yut
    mvt

    is it possible ?
    If it is not possible then is it possible to get atleast part of the column?


    I am using vc++ 2005 MFC dialog based
    MS Access 2003

    -thiyagu


    I believe nothing is impossible after learned programming

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Try this:

    SELECT DISTINCT Right(address, 3)
    FROM TableName
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Welcome to DevX

    Or
    Code:
    SELECT id, address FROM tablename WHERE RIGHT(address,3) = 'mvp'
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  4. #4
    Join Date
    Nov 2008
    Posts
    2
    Quote Originally Posted by Phil Weber View Post
    Try this:

    SELECT DISTINCT Right(address, 3)
    FROM TableName

    the above query worked well.

    this is also another solution

    select distinct mid(address,inSTR(address,'-')+1,len(address)) as dADDRESS from MASTER
    Last edited by thiyagu135; 11-20-2008 at 02:39 AM. Reason: column name changed

  5. #5
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    You could also do
    Code:
    select mid(address,inSTR(address,'-')+1,len(address)) as dADDRESS 
    from MASTER 
    group by address
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. help with sparse matrix
    By jrhaley123 in forum Java
    Replies: 8
    Last Post: 09-28-2013, 10:48 PM
  2. Replies: 2
    Last Post: 02-07-2007, 09:20 PM
  3. DataGrid Column Headers
    By Greg Rothlander in forum ASP.NET
    Replies: 3
    Last Post: 10-23-2003, 02:55 PM
  4. DISTINCT column from non distinct record
    By Danielle in forum Database
    Replies: 4
    Last Post: 05-16-2001, 09:02 AM
  5. Select Distinct column
    By Andy in forum VB Classic
    Replies: 1
    Last Post: 07-07-2000, 07:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center