If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Help with SQL,

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-18-04, 10:54
quigleyd quigleyd is offline
Registered User
 
Join Date: Nov 2002
Location: Delaware
Posts: 186
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
Reply With Quote
  #2 (permalink)  
Old 08-18-04, 12:24
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
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)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On