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 > Date function

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-06-12, 05:05
thawfii88 thawfii88 is offline
Registered User
 
Join Date: Nov 2011
Posts: 13
Date function

Hi ,

how to compare the yesterdays values and the todays in a table based on the inserted date. the output should show the difference alone. i have a separate column for updated date but i should not use (current date - 1 days) to get the yesterday's values

Pls find the description of that table.

Data type Column
Column name schema Data type name Length Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
NAME SYSIBM VARCHAR 32 0 Yes
VALUE SYSIBM VARCHAR 256 0 Yes
VALUE_FLAGS SYSIBM VARCHAR 10 0 Yes
DEFERRED_VALUE SYSIBM VARCHAR 256 0 Yes
DEFERRED_VALUE_FLAGS SYSIBM VARCHAR 10 0 Yes
DATATYPE SYSIBM VARCHAR 128 0 Yes
DBPARTITIONNUM SYSIBM SMALLINT 2 0 Yes
UPDATED_DATE SYSIBM DATE 4 0 Yes

any help is appreciated

Thanks
TJ

Last edited by thawfii88; 01-06-12 at 05:08. Reason: chumma
Reply With Quote
  #2 (permalink)  
Old 01-06-12, 05:52
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Please publish sample/test data and expected output from the sample/test data
with one of the following format
(1) CREATE TABLE statement and INSERT statement.
or
(2) WITH common-table-expression.
Reply With Quote
  #3 (permalink)  
Old 01-06-12, 06:01
thawfii88 thawfii88 is offline
Registered User
 
Join Date: Nov 2011
Posts: 13
NAME VALUE UPDATED_DATE
---- ----- ---------------

avg_appl 5 1/06/2012

app_ctl_heap_sz 16384 1/06/2012

avg_appl 3 1/07/2012

app_ctl_heap_sz 16384 1/07/2012



we have to compare the rows based on the updated_date (between yesterday and today) and return the yesterday's value incase of any change.


avg_appl 5 1/06/2012

note : ther are nearly 800 rows updated daily it has to compare all the 800 rows of yesterday and today


by TJ
Reply With Quote
  #4 (permalink)  
Old 01-06-12, 06:45
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
A solution may be to use LEAD OLAP specification.
Reply With Quote
  #5 (permalink)  
Old 01-06-12, 07:22
thawfii88 thawfii88 is offline
Registered User
 
Join Date: Nov 2011
Posts: 13
any other way ?
Reply With Quote
  #6 (permalink)  
Old 01-06-12, 07:57
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Quote:
any other way ?
Why?
Was there any issue on LEAD OLAP specification?

Please see Information Center about OLAP specifications including LEAD
OLAP specifications - IBM DB2 9.7 for Linux, UNIX, and Windows
Reply With Quote
  #7 (permalink)  
Old 01-06-12, 19:07
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Could you make a required query?

If you published sample/test data with the format I hoped, I could show you an example.
Quote:
Originally Posted by tonkuma View Post
Please publish sample/test data and expected output from the sample/test data
with one of the following format
(1) CREATE TABLE statement and INSERT statement.
or
(2) WITH common-table-expression.
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