#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    2
    Rep Power
    0

    Select statement help


    Hi,

    I will try to explain my problem as simple as possible...I will try...
    I have a simple select statement:
    Select column1,column2 FROM Table

    I am executing succcessfully the select statement which fetch some records, different every time. Now based on an int value Y (different every time the select is execute) I want to add an extra column(Column3) on my select statement in which starting from the first row until the Y rows to assign a value and after the Y number rows exceeded to assign some other value to column3. For example, If Y is equal to 3, I want the first 3 rows on my select statement to have a column3 = somevalue and the rest of the rows to have column3 = someOthervalue
    How can I modify my Select statement in order to accomplish my scenario. Maybe using a loop I can do this...Are their any other ways. I want to know if any, to choose the appropriate one.

    Thanks
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,140
    Rep Power
    4274
    it would be ~so~ much better to do this type of processing in the application layer using a programming language like vb or whatever
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    2
    Rep Power
    0
    I wish I had that option....Is an SQL Function
  6. #4
  7. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,140
    Rep Power
    4274
    Originally Posted by b1naryMan
    Is an SQL Function
    no, isn't
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo