Results 1 to 2 of 2

Thread: Help with SQL,

  1. #1
    Join Date
    Nov 2002
    Location
    Delaware
    Posts
    186

    Unanswered: Help with SQL,

    AIX 5.2, DB2 V8, FIXPAk 5 (bunch of special builds)


    I have a the following table:
    name schema name Length Scale Nulls
    ------------------------------ --------- ------------------ -------- ----- -----
    NAME SYSIBM INTEGER 4 0 No
    CLOSETS SYSIBM VARCHAR 14 0 No
    LASTMOVE SYSIBM VARCHAR 14 0 No
    BACKUPTS SYSIBM VARCHAR 14 0 Yes
    OBJID SYSIBM INTEGER 4 0 No
    SIZE SYSIBM INTEGER 4 0 No
    MIRROR_FLAG SYSIBM CHARACTER 1 0 Yes


    I am running the following SQL to get totals for each day

    select count(*) from sapr3.db6logfile where lastmove like '20040817%'

    Now my issue, I have tried to change it so I can run this and supply a year and month like '200408%' and group and order it by the date so I can get a months worth of data instead of individual days. My ouput would contain 2 columns, First column is the date, 2nd is the #of records for that date.

    I appreciate any help anybody can give me. I havn't done that much SQL in 5 years now and I'm getting very rusty.
    David Quigley

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    If I understand your question correctly the following should work:
    Code:
    select substr(lastmove, 1, 6), count(*) from ... where lastmove like ... group by substr(lastmove,1,6)

Posting Permissions

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