Teststand SQL reuest get MAX of a Column

Spoiler (Highlight to read)
Hello,
In Teststand 3.1, I try to get the MAX of a column called  Col1 in the table myTAB.
To do that; I have writen in the Open Statement the following request
SELECT MAX(myTAB.Col1) FROM myTAB" Thanks. Correct execution in teststand
Question : How do I get the result with the SQL Action Step
Thank you by advance for your help
Solved!
Go to Solution.

Hello Rodéric,
Thank you very much for the answer.
I tried your suggestion as it is but unfortunatelly Teststand gives back an error because it can't manage correctly the locals.max in the request.
However I tried other may your idea of using the key word "as" :
First I use :
Open Statement : SELECT MAX(myTAB.Col1) as MAXI FROM myTAB
I don't know how teststand manage the "variable" MAXI.
But when I secondly add the step
SQL Action : Get - Retrive Values from record with as Column/Parameter Values:
Name/Number : "MAXI"
Values : Locals.Max
It works correctly
Thank you a lot
Ham

Similar Messages

  • SQL Help getting Max() date....

    Hi gurus, Here is my situation:
    Here is the sample data:
    Policy_Id Policy-Exp_Dt COl_1
    123_____10/30/2008 __ 333
    123_____ 09/25/2008___445
    123_____ 08/30/2008___443
    Here i have to get the Policy-Exp_Dt from the second row; In other words for all rows which have a similar Policy_Id i should first find out the max(Policy-Exp_Dt) and get the next smallest available date to that.
    I have tried using
    select Policy_Id, COl_1, Policy_Exp_Dt from
    table_1
    where Policy-Exp_Dt = (select max(Policy-Exp_Dt)-1 from
    table_1 a
    where a.policy_id = table_1.policy_id)
    but here i am getting the value = 10/30/2008 - 1 which is 10/29/2008 but i need the value 9/25/2008 which is the next available date less than the max() date.
    Please Advise.
    Edited by: user521009 on Jan 9, 2009 1:56 PM

    I thought to use lag - maybe not as appropriate a ranking functions.
    Also we have a case where there is only One record for a policy - exclude this I guess!
    drop table Max_but_One;
    create table Max_but_One
      Policy_Id      integer      not null,
      Policy_Expires date         not null,
      Policy_Note    varchar2(20) not null
    -- Standard data
    insert into Max_but_One values (123, to_date('30-08-2008','dd-mm-yyyy'), 'First note');
    insert into Max_but_One values (123, to_date('25-09-2008','dd-mm-yyyy'), 'Second note');
    insert into Max_but_One values (123, to_date('30-10-2008','dd-mm-yyyy'), 'Third note');
    -- Standard data again for double check
    insert into Max_but_One values (223, to_date('01-11-2008','dd-mm-yyyy'), 'First note');
    insert into Max_but_One values (223, to_date('02-11-2008','dd-mm-yyyy'), 'Second note');
    -- Only one record for a policy!
    insert into Max_but_One values (323, to_date('01-12-2008','dd-mm-yyyy'), 'First note');
    -- Two or more records for a policy both having the same date which is prior to the max
    insert into Max_but_One values (423, to_date('10-12-2008','dd-mm-yyyy'), 'First note');
    insert into Max_but_One values (423, to_date('10-12-2008','dd-mm-yyyy'), 'Second note');
    insert into Max_but_One values (423, to_date('11-12-2008','dd-mm-yyyy'), 'Third note');
    break on Policy_ID
    select Policy_Id, Policy_Expires, Policy_Note
      from Max_but_One
    order by Policy_Id, Policy_Expires
    POLICY_ID POLICY_EX POLICY_NOTE
           123 30-AUG-08 First note
               25-SEP-08 Second note
               30-OCT-08 Third note
           223 01-NOV-08 First note
               02-NOV-08 Second note
           323 01-DEC-08 First note
           423 10-DEC-08 First note
               10-DEC-08 Second note
               11-DEC-08 Third note
    -- Max Policy_Expires
    select t.*
      from (select Policy_Id, Policy_Expires, Policy_Note
                  ,max(Policy_Expires) over (partition by Policy_Id) as Max_Policy_Expires
              from Max_but_One
           ) t
    where t.Policy_Expires = t.Max_Policy_Expires
    POLICY_ID POLICY_EX POLICY_NOTE          MAX_POLIC
           123 30-OCT-08 Third note           30-OCT-08
           223 02-NOV-08 Second note          02-NOV-08
           323 01-DEC-08 First note           01-DEC-08
           423 11-DEC-08 Third note           11-DEC-08
    -- Using LAG
    select t.Policy_Id
          ,t.Prior_Policy_Expires as Policy_Expires
          ,t.Prior_Policy_Note    as Policy_Note
      from (select Policy_Id, Policy_Expires, Policy_Note
                  ,max(Policy_Expires) over (partition by Policy_Id) as Max_Policy_Expires
                ,lag(Policy_Expires) over (partition by Policy_Id order by Policy_Expires) as Prior_Policy_Expires
                  ,lag(Policy_Note)    over (partition by Policy_Id order by Policy_Expires) as Prior_Policy_Note
              from Max_but_One
           ) t
    where t.Policy_Expires = t.Max_Policy_Expires
    POLICY_ID POLICY_EX POLICY_NOTE
           123 25-SEP-08 Second note
           223 01-NOV-08 First note
           323
           423 10-DEC-08 Second note
    -- To exclude the single record policy then add and t.Prior_Policy_Expires is not null
    select t.Policy_Id
          ,t.Prior_Policy_Expires as Policy_Expires
          ,t.Prior_Policy_Note    as Policy_Note
      from (select Policy_Id, Policy_Expires, Policy_Note
                  ,max(Policy_Expires) over (partition by Policy_Id) as Max_Policy_Expires
                ,lag(Policy_Expires) over (partition by Policy_Id order by Policy_Expires) as Prior_Policy_Expires
                  ,lag(Policy_Note)    over (partition by Policy_Id order by Policy_Expires) as Prior_Policy_Note
              from Max_but_One
           ) t
    where t.Policy_Expires = t.Max_Policy_Expires
       and t.Prior_Policy_Expires is not null
    POLICY_ID POLICY_EX POLICY_NOTE
           123 25-SEP-08 Second note
           223 01-NOV-08 First note
           423 10-DEC-08 Second note
    -- 423 is randomly picked here - could equally have got {423, 10-DEC-08, First note}

  • In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String

    In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String , for executing the Stored Procedure with Current date as the input .

    Hi Srinath,
    The below blog might be useful
    http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/03/06/executing-stored-procedure-from-sender-adapter-in-sap-pi-71
    PI/XI: Sender JDBC adapter for Oracle stored procedures in 5 days
    regards,
    Harish

  • How to get list in single column in a query

    Hello.
    I wonder if there is a way of getting with one query (no pl/sql code) a whole list of columns with a separator between them.
    I know I can get that without the separators with a cursor expression:
    SQL> with test_table as (
      2  select 1 col1, 'a' col2 from dual
      3  union
      4  select 1 col1, 'b' col2 from dual
      5  union
      6  select 1 col1, 'c' col2 from dual
      7  union
      8  select 2 col1, 'a' col2 from dual
      9  union
    10  select 2 col1, 'c' col2 from dual
    11  union
    12  select 2 col1, 'd' col2 from dual
    13  union
    14  select 2 col1, 'z' col2 from dual
    15  )
    16  select col1, cursor (select b.col2 from test_table b where b.col1 = a.col1 order by b.col2) col2_list from test_table a
    17  group by col1
    18  /
          COL1 COL2_LIST
             1 CURSOR STATEMENT : 2
    CURSOR STATEMENT : 2
    C
    a
    b
    c
             2 CURSOR STATEMENT : 2
    CURSOR STATEMENT : 2
    C
    a
    c
    d
    zBut the output that I want is (using the separator ';'):
          COL1 COL2_LIST
             1 a;b;c
             2 a;c;d;zI do not know how to handle a cursor expression without using a pl/sql block of function. Can it be done using analytic functions?
    Thanks in advance.

    Like this...
    SQL> ed
    Wrote file afiedt.buf
      1  with test_table as (
      2    select 1 col1, 'a' col2 from dual union
      3    select 1 col1, 'b' col2 from dual union
      4    select 1 col1, 'c' col2 from dual union
      5    select 2 col1, 'a' col2 from dual union
      6    select 2 col1, 'c' col2 from dual union
      7    select 2 col1, 'd' col2 from dual union
      8    select 2 col1, 'z' col2 from dual)
      9  --
    10  select col1, ltrim(sys_connect_by_path(col2,','),',') as col2
    11  from
    12    (select col1, col2, row_number() over (partition by col1 order by col2) rn
    13    from test_table)
    14  where connect_by_isleaf = 1
    15  connect by col1 = prior col1
    16  and rn = prior rn+1
    17* start with rn = 1
    SQL> /
          COL1 COL2
             1 a,b,c
             2 a,c,d,z
    SQL>

  • How to get the number of columns in a result set???

    hi everyone..
    i am trying to establish a servlet applet communication....
    my applet send the sql query to the servlet as serialised string and then the servlet executes the query...
    Since i need to pass the result back to the applet, i thaught of passing the whole reult set to the applet..but that seems to be not possible..
    so i thaught of storing my result set data in a vector and then pass the vector,but the first problem that i came across is that how to get the number of colums in a result set....
    so is there a way to get the number of columns in a result set...???
    and also i would like to know if it possible to send my whole result set to the applet bye serialization or by any method...???
    thanx in advance

    You shouldn't do. It expenses resources (you should always close the ResultSet and the Statement as fast as possible). Simply gently process it into a Collection or Map of DTO's. Those are serializable.

  • APEX CSS - How do I get data in report columns to wrap?

    I found information here http://www.orafaq.com/wiki/APEX_FAQ
    About How do I get data in report columns to wrap?
    This works and another way to do it is by adding the CSS directly into the
    Home>Application Builder>Application 137>Page 1>Report Attributes>Column Attributes page
    in the Column Formatting area. I added 'white-space:normal' and this works in FF but in
    IE it has a different behavior.
    In FireFox
    testasdgadhad
    gadfadgadgadg
    adgafhsrgjsgnsfg
    nsdfbadfafhafha
    dfhadfh
    In Internet Explorer
    testasdgadhad gadfadgadgadg adgafhsrgjsgnsfg nsdfbadfafhafha dfhadfh
    Is there a way to force it so it display in IE the same way that it displays in FF?
    The correct display format is FF.
    Thanks,
    Nestor :)

    I have try this because I found it during a search and it makes no difference in IE.
    This is what I am using now 'display: block; width: 100px;max-width:100px;white-space:normal'
    I also tried 'display:block; width:500px'
    If I use the values 'normal' or 'pre' for white-space' it works in FireFox but not in IE, The display block
    does not seem to make a difference. It seems that all I need is 'white-space:normal' but again
    it does not works on IE.
    Thanks,
    Nestor :-)

  • SQL LOADER: how to load CLOB column using stored function

    Hi,
    I am a newbie of sql loader. Everything seems to be fine until I hit a
    road block - the CLOB column type. I want to load data into the clob
    column using a stored function. I need to do some manipulation on the
    data before it gets saved to that column. But I got this error when I
    run the sql loader.
    SQL*Loader-309: No SQL string allowed as part of "DATA" field
    specification
    DATA is my CLOB type column.
    here is the content of the control file:
    LOAD DATA
    INFILE 'test.csv'
    BADFILE 'test.bad'
    DISCARDFILE 'test.dsc'
    REPLACE
    INTO TABLE test_table
    FIELDS TERMINATED BY ','
    OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    codeid          BOUNDFILLER,
    reason          BOUNDFILLER,
    Checkstamp     "to_date(:CHECKSTAMP, 'mm/dd/yyyy')",
    "DATA"          "GetContent(:codeid, :reason)"
    All references are suggesting to use a file to load data on
    CLOB column but I want to use a function in which it generates
    the content to be saved into the column.
    Any help is greatly appreciated.
    Thanks,
    Baldwin
    MISICompany

    *** Duplicate Post ... Please Ignore ***

  • How to get max and min salary in a table

    How to get max and min salary in a table

    SQL> select max(sal),min(sal) from emp;
      MAX(SAL)   MIN(SAL)
          5512        800
    SQL>

  • Max number of columns in a Webi report

    In a worst-case scenario test, I requested about 1700 columns in a Webi report, but only a little more than 300 appeared in the SQL; a TOAD request for the same 1700 columns was successful. Is there an upper limit for the number of objects that can appear in a Webi report? Is there a parameter that could increase the limit?

    My eyes read the first half and my brian assumed the second half.
    I dont think there is a limitaion on the number of objects that a WebI report can pull.
    The only limitation I know of is the maximum number of column that you can display in the report panel; the max number is 100,000.
    With the limit on the max number of column diplay in a WebI report can be translated into the max number of columns in the query panel.
    This setting is in CMC> Applications>Web Intelligence-->Quick Display mode

  • Max No. of columns returned in Query Template

    Hi All,
    Is there any limit to the max number of columns that can be returned for a sql query using the Query Template?
    Regards,
    Arijeet

    Hi Rick,
    I am basically querying a database table which has a large number of columns. Of which I need only a few. Unfortunately though some of the columns I need are not in those that are shown by default when I do a SELECT * or in the list of columns that show up in the Query Template. I am using UDS to connect to the other system and when I try to SELECT the columns which are of interest to me the connection is reset and the UDS Instance for that connection stops. I could access all the columns in the BLS so I am presently using a work around by running an xacute query to show me the data.
    Regards,
    Arijeet

  • Using sql functions (min, max, avg) on varray or table collection

    Hi,
    I would like to know if there is a way to use sql function or oracle sql function like Min,Max, Avg or percentile_cont on varray or table collection ?
    Does anyone encountered this type of problem ?
    Thanks

    Yes you can apply Min,Max, Avg... if varray or table collection type is SQL (created in the databaase) UDF, not PL/SQL declared type:
    SQL> set serveroutput on
    SQL> declare
      2      type str_tbl_type is table of varchar2(4000);
      3      str_tbl str_tbl_type := str_tbl_type('X','A','D','ZZZ');
      4      max_val varchar2(4000);
      5  begin
      6      select max(column_value)
      7        into max_val
      8        from table(str_tbl);
      9      dbms_output.put_line('Max value is "' || max_val || '"');
    10  end;
    11  /
          from table(str_tbl);
    ERROR at line 8:
    ORA-06550: line 8, column 18:
    PLS-00642: local collection types not allowed in SQL statements
    ORA-06550: line 8, column 12:
    PL/SQL: ORA-22905: cannot access rows from a non-nested table item
    ORA-06550: line 6, column 5:
    PL/SQL: SQL Statement ignored
    SQL> create or replace type str_tbl_type is table of varchar2(4000);
      2  /
    Type created.
    SQL> declare
      2      str_tbl str_tbl_type := str_tbl_type('X','A','D','ZZZ');
      3      max_val varchar2(4000);
      4  begin
      5      select max(column_value)
      6        into max_val
      7        from table(str_tbl);
      8      dbms_output.put_line('Max value is "' || max_val || '"');
      9  end;
    10  /
    Max value is "ZZZ"
    PL/SQL procedure successfully completed.
    SQL> SY.

  • ObjectGUID in a ms sql databse in a varchar(100) column

    HI
    I'm doing
       returnAsBinary = "objectGUID"
    in a <cfldap> query.
    I was thinking of storing this value returned by objectGUID in a ms sql databse in a varchar(100) column as a primary key. Can you see any pitfalls with this method?

    Mabye this is the solution from another website:
    Can anyone please explain how to get the objectguid binary attribute from Active  Directory using cfldap and store it in the database? I need this so as to maintain a global unique id both in the AD and in my  database for the users.  Thanks
    You'll probably have to use JLDAP for this - CFLDAP has many shortcomings that  we've used JLDAP to work around. It's a very simple API and everything works from  within CF. I've blogged a few of things we've done, so that should get you  started:
    http://www.d-ross.org/index.cfm?objectid=9C65EEF0-508B-E116-6F30CA79F5BFDE07
    http://www.d-ross.org/index.cfm?objectid=9C65EF0F-508B-E116-6F851C474448E08B
    http://www.d-ross.org/index.cfm?objectid=9C65ED79-508B-E116-6F81AF8F75FB40AD
    Terry Ryan used a lot of this work to create a CFC that you can use:

  • When Import get Error-00904 Invalid Column Name

    Hi all,
    I'm using DI Premium 3.0 with Oracle 10.2.0.1.0 repository. I'm trying to connect Oracle 8.1.4.7.1 (8i) but when i going to import tables get Error-00904 Invalid Column Name. If i connect to Oracle 10.2.0.4.0 don't get error.
    Trying from DI XI R2 (11.7) with Oracle 10.2.0.2.0 repository, to connect Oracle 8.1.4.7.1 (8i) don´t get error!
    Is error from Oracle repository version?
    Thanks in advance.
    Jorge

    Hi Manoj,
    This is the output:
    SQL> desc all_tab_columns
    Name                                      Null?    Type
    OWNER                                      NOT NULL      VARCHAR2(30)
    TABLE_NAME                             NOT NULL      VARCHAR2(30)
    COLUMN_NAME                          NOT NULL      VARCHAR2(30)
    DATA_TYPE                                           VARCHAR2(106)
    DATA_TYPE_MOD                                           VARCHAR2(3)
    DATA_TYPE_OWNER                                         VARCHAR2(30)
    DATA_LENGTH                           NOT NULL      NUMBER
    DATA_PRECISION                                          NUMBER
    DATA_SCALE                                                   NUMBER
    NULLABLE                                                     VARCHAR2(1)
    COLUMN_ID                                 NOT NULL      NUMBER
    DEFAULT_LENGTH                                          NUMBER
    DATA_DEFAULT                                            LONG
    NUM_DISTINCT                                                 NUMBER
    LOW_VALUE                                                    RAW(32)
    HIGH_VALUE                                                   RAW(32)
    DENSITY                                                      NUMBER
    NUM_NULLS                                                    NUMBER
    NUM_BUCKETS                                             NUMBER
    LAST_ANALYZED                                           DATE
    SAMPLE_SIZE                                                  NUMBER
    CHARACTER_SET_NAME                                    VARCHAR2(44)
    CHAR_COL_DECL_LENGTH                                 NUMBER
    GLOBAL_STATS                                            VARCHAR2(3)
    USER_STATS                                                   VARCHAR2(3)
    AVG_COL_LEN                                             NUMBER
    Thanks for your help.
    Jorge

  • Problem to get max string value

    Hi
    my problem is i don't get correct result when i get max string value from my table. for example, it returns '9' as max value while i have some bigger string values like 73, 80,65, ...
    i found
    some solutions to handle this problem (like converting to char or adding some zero in the begining of my value) but it does not appropriate for my situation because my string value maybe everything (some of my customers can use numbers while some other
    else can use alphabetical+numbers)!.
    can anybody help me ?
    thanks in advance
    http://www.codeproject.com/KB/codegen/DatabaseHelper.aspx

    When I see NVARCHAR(50)(50) I am pretty sure the data was declared by an ACCESS programmer who has no idea what he is doing. Do you really have first
    and last names that need fifty UNICODE characters ?  You will get them!  If you invite garbage data, it will come. The USPS uses VARCHAR(20) for names; this has to do with the size of mailing labels and the fact
    that Latin-1 is required by ISO in ALL languages. 
    lease read the  "Stairway to Data" series and pay attention to last sections on the design of encoding schemes. What you have is useless and dangerous because it has no data integrity.  Tag
    numbers (learn what that means, please) need a regular expression and I like to have a check digit. My first guess, without an specs is that you need something like this:  
    patient _case_nbr CHAR() NOT NULL PRIMARY KEY
     CHECK (patient _case_nbr 
      LIKE '[ ABC][0-9][0-9][0-9][0-9][0-9]')
    Fixed length for the forms and display, characters limtied to the Latin-1 Unicode set, and easy to sort. 
     http://www.sqlservercentral.com/articles/Database+Design/72612/)
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • SSIS Package : Needs SQL Tables get refreshed every hour

    Hello,
    I have created a SSIS Package which includes,
    Step 1 : Using Execute SQL Task to truncate all the tables
    Step 2 : Data Flow Tasks to extract data from SharePoint lists and fill the SQL Tables for SSRS Reporting from that.
    Requirement is to refresh SQL Tables every hour. I can do this using SQL Server Agent Job to run SSIS Package.
    But, I am not sure is this the feasible way of do this, as we are truncating all the tables. There are around 10-15 tables. Database size is also not large.
    Is there any in SSIS to impose only changes done in the SharePoint list to SQL tables rather than truncating them and creating new ones?
    Thank you,
    Mittal.

    @Visakh,
    Yes I am getting Created,CreatedBy, Modified, ModifiedBy audit fields data from all the SharePoint List.
    So, can we just trust these fields and update tables accordingly ?
    And how can I do this using SSIS ? Is there any particular control I can use to compare the data and time and update the SQL Tables?
    Thank you,
    Mittal.
    Yes. Provided they have proper data thiat should work fine.
    Yes you can use it inside SSIS
    You can have a logic like below
    1. In execute sql task capture max date for the source table
    2. Use data flow task with source query having filter based on date field
    ie like
    WHERE Modified > ?
    And map parameter to maxdate
    3. add destination step to populate data
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Maybe you are looking for

  • HDMI output not working on HP Pavilion 15

    Hi guys, i am new here on HP Forum. My problems started when i got my new laptop and i HATED windows 8. So a friend of mine had a disc with Windows 7 on it. After the installation nothing worked, Not wlan, USB, HDMI and so on, I serched for days for

  • Ipod not showing up in itunes or ipod updater

    my ipod worked fine...then i realized i had to install the ipod updater so i did that...then by accident i unplugged my ipod video while it said do not disconnect, now my ipod doesn't show up in itunes, but does in my computer...also my wireless usb

  • Which LCD monitor to get? Dell or Apple?

    Hello everyone! Well, I have decided to make the jump from CRT to LCD. I see that Dell has one similar to the Apple Cinema Display which is 20 inches. I am somewhat confused as to what monitor I should get since to me the Dell looks just as good as t

  • CFFEED & Namespace Declaration

    I would appreciate some help with generating rss feed for Google Merchant.  I am trying to use cffeed to generate the xml file which I am good with.  The issue is formatting it to google's specifications and their namespace declaration (<g:price></g:

  • PDF files print light

    Both my consultant and myself use Reader X1 to print pdf files made in 995. When he prints the pdf file that come out ok but when I try to print the same pdf it comes out light. Does anyone have any suggestions as to what may be causing this or how t