1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Other Basic SQL help

Discussion in 'Software' started by TheStockBroker, 4 Jul 2013.

  1. TheStockBroker

    TheStockBroker Modder

    Joined:
    19 Nov 2009
    Posts:
    1,533
    Likes Received:
    110
    Morning all,

    Noob needs a quick hand here, I've googled as best I can - but I'm suffering because what I'm trying to do partially defeats the purpose of a relational database.

    I have a table "Property_Information".

    There's a column "PLCode" (amongst others), which contains non-unique values. The query I'd like selects a single record per PLCode, and the rest of the information attached to that record.

    E.G. SELECT DISTINCT PLCODE FROM ...

    Would provide me with the list of one of each PLCODE in the column - great - I just need to append the remainder of the data from that record. (Or even better, be able to define what other fields I'd like to retrieve)

    I understand that this is not really what a database is for, but to achieve some sample data, it would be perfect for what I need. I don't care which record per PLCODE is retrieved.

    Your help greatly appreciated.

    TSB
     
  2. BentAnat

    BentAnat Software Dev

    Joined:
    26 Jun 2008
    Posts:
    7,230
    Likes Received:
    219
    Possibly not the easiest or fastest in terms of execution, but if it's once of, for the sake of quick results over efficient code, I'd cursor through it, populating a temp table.
     
  3. Daedelus

    Daedelus What's a Dremel?

    Joined:
    7 May 2009
    Posts:
    253
    Likes Received:
    12
    So as I understand it, you have a table something like this:

    Code:
    PLCode Category Data
    AAAA Name Foo
    AAAA Date 2012-05-05
    BBBB Name Bar
    BBBB Date 2013-03-03
    
    And you want to query the data to get a result like:

    Code:
    PLCODE Name Date
    AAAA Foo 2012-05-05
    BBBB Bar 2013-03-03
    Is that correct?
     

Share This Page