Consulting

Results 1 to 2 of 2

Thread: Loop in SQL

  1. #1
    VBAX Newbie
    Joined
    Sep 2014
    Posts
    4
    Location

    Loop in SQL

    Hey. I have a question about looping in SQL. I want to convert some given logic into SQL language (I am new to SQL). I am wondering whether it is possible to put the loop inside a CASE WHEN statement ? If anyone knows please consult me on this The original logic i am working with is this:

    "IF v1=1 AND v2<>333 READ EACH v3 OCCURRENCE UNTIL YOU LOCATE THE 1ST OCCURRENCE WHERE v4=2 AND v5<=v6 THEN MOVE v7 ELSE MOVE v8".

    I start converting into SQL syntax: " CASE WHEN v1=1 AND v2<>333... " and then not sure how to proceed.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You can do the IF with a WHERE clause, but what does MOVE v7 ELSE MOVE v8 mean? Why do you want the 1st occurrence?

    Probably better to explain what you need to do rather than asking how to convert a logic statement.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •