need help with a select and order problem

Discussion in 'ASP General' started by Dan, Apr 21, 2004.

  1. Dan

    Dan Guest

    I have a forum running on ASP that allows people to set how many days
    they want to see of messages (cutoffdate). The board is set up with
    the following select statement - "SELECT * FROM Forum WHERE
    DateCreated > cutoffdate ORDER BY ThreadID, FieldSortCode" The
    threadid is a sequential number for new threads and the fieldsortcode
    is sequential for each reply to the parent thread. For example, a new
    thread would get a threadid of 8040 and a sortcode of 8040. A reply
    to this thread would get a threadid of 8040 and a sortcode of 8040.1.
    It gets a bit more complicated when there's a reply to a reply...but I
    think this gives an idea on how the messages are set up.

    If someone comes along and replys to a post beyond the person's
    cutoffdate, then the reply shows up at the very bottom of the message
    board as it should based on threadid and sortcode. Is it possible to
    construct a select statement that would order a message with a parent
    message beyond the cutoff date at the top of the list. So when
    someone replys to a message that is beyond the cutoff date, it will
    show up at the top and not at the bottom? I'm thinking I might have
    to order by date and sort code and not by sort code alone? Or am I
    dreaming?

    Dan
     
    Dan, Apr 21, 2004
    #1
    1. Advertising

  2. "Dan" <> wrote in message
    news:...
    > I have a forum running on ASP that allows people to set how many days
    > they want to see of messages (cutoffdate). The board is set up with
    > the following select statement - "SELECT * FROM Forum WHERE
    > DateCreated > cutoffdate ORDER BY ThreadID, FieldSortCode" The
    > threadid is a sequential number for new threads and the fieldsortcode
    > is sequential for each reply to the parent thread. For example, a new
    > thread would get a threadid of 8040 and a sortcode of 8040. A reply
    > to this thread would get a threadid of 8040 and a sortcode of 8040.1.
    > It gets a bit more complicated when there's a reply to a reply...but I
    > think this gives an idea on how the messages are set up.
    >
    > If someone comes along and replys to a post beyond the person's
    > cutoffdate, then the reply shows up at the very bottom of the message
    > board as it should based on threadid and sortcode. Is it possible to
    > construct a select statement that would order a message with a parent
    > message beyond the cutoff date at the top of the list. So when
    > someone replys to a message that is beyond the cutoff date, it will
    > show up at the top and not at the bottom? I'm thinking I might have
    > to order by date and sort code and not by sort code alone? Or am I
    > dreaming?
    >
    > Dan


    Please provide the following:
    1. Database
    2. Version
    3. Data Definition Language (CREATE TABLE ...)
    4. Sample Data
    5. Desired output

    -Chris Hohmann
     
    Chris Hohmann, Apr 21, 2004
    #2
    1. Advertising

  3. Dan

    roger Guest

    "Dan" wrote

    > If someone comes along and replys to a post beyond the person's
    > cutoffdate, then the reply shows up at the very bottom of the message
    > board as it should based on threadid and sortcode. Is it possible to
    > construct a select statement that would order a message with a parent
    > message beyond the cutoff date at the top of the list.


    Does this work?

    SELECT * FROM Forum WHERE
    DateCreated > cutoffdate ORDER BY (DateCreated > cutoffdate), ThreadID,
    FieldSortCode

    Of course, I'm only guessing about the following -

    True = -1
    False = 0
    That the syntax works on your version of SQL


    --
    roger
     
    roger, Apr 21, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    8,928
    nitin
    Mar 24, 2005
  2. Bob
    Replies:
    1
    Views:
    1,629
  3. Soren Kuula
    Replies:
    2
    Views:
    504
    Soren Kuula
    Feb 1, 2004
  4. Stephan Kämper
    Replies:
    2
    Views:
    240
    Stephan Kämper
    Jan 18, 2004
  5. palmiere
    Replies:
    1
    Views:
    413
    Erwin Moller
    Feb 9, 2004
Loading...

Share This Page