-1

I have a TEMP TABLE with an alphanumeric column and I want to get the range of records on basis of 2 filters.

**Filters:** Begin filter and End filter.

**For Example: Column data:**
A123
A145
B002
B234
C095
C456
D001
D345

Begin filter -> A14 and End filter -> D12

**Expected Result:**
A145
B002
B234
C095
C456
D001

Is there any way to do it?

Thanks in Advance!

whereisSQL
  • 638
  • 2
  • 13
  • 23

1 Answers1

3

Do you mean something like this?

FOR EACH ttName 
   WHERE ttName.FieldName >= "A14" and ttName.FieldName <= "D12"
   NO-LOCK:

        /* do stuff */

END.
Tim Kuehn
  • 3,201
  • 1
  • 17
  • 23
  • It will work, but I want something like between in sql. If there is no record with D12, then it should automatically pick previous one. – user3797063 Aug 14 '15 at 15:18
  • 2
    Progress is NOT SQL. The more you try to make it be like SQL the unhappier you will be. – Tom Bascom Aug 14 '15 at 16:28
  • @Tom is there any way to get the between functionality in progress?? – user3797063 Aug 14 '15 at 16:45
  • No. Progress is not SQL. You cannot successfully use SQL syntax within a 4gl program. The correct way to do this is as Tim has shown. – Tom Bascom Aug 14 '15 at 17:13
  • @Tom I already did that way, but requirement is different. Okay thank for your time guys – user3797063 Aug 14 '15 at 17:31
  • Perhaps you should state the "requirement"? From your original question it certainly looks like the requirement has been met. If the code must somehow say "between" somewhere try embedding a comment. – Tom Bascom Aug 14 '15 at 17:36
  • @TomBascom Apologies for late reply Requirement: 1) No End Range Record exists, return Display Range between the Begin Record and the assumed End Record. 2) No Begin Range Record exists, return Display Range between the assumed Begin Record and the last End Record. 3) No Begin Range and no End Range Record, return Display Range between the assumed Begin Record and the last End Record. Thanks – user3797063 Sep 01 '15 at 09:33
  • @TomBascom Requirement is in SQL query mention below: SELECT * FROM test.temp where tempcol between 'A14' and 'D12' If we can get the result in Progress as above query getting in SQL, my requirement will be fulfilled. Thanks – user3797063 Sep 01 '15 at 09:35
  • It looks to me like Tim's solution meets your requirement perfectly. – Tom Bascom Sep 01 '15 at 11:56
  • @TomBascom As mentioned in my question, there is no 'D12' records in the grid. So according to Tim's solution it will show all the record ttName.FieldName >= 'A14'. It means D345 also will be display in the grid. What do you think? – user3797063 Sep 01 '15 at 12:43
  • 3
    I think that you are probably misunderstanding how AND works and that you might want to try actually running Tim's code. – Tom Bascom Sep 01 '15 at 13:29