Quantcast
Channel: Teradata Forums - Database
Viewing all 14773 articles
Browse latest View live

Upgrade TD14.10 and Reserved Words - response (6) by syedrehanahmad

$
0
0

Hello All,
 
If anyone of you have resolved the issue of reserved words in TD14.10, please help me with the approach/methodology. I would be helpful to you.
 
Thanks,
Syed


Determine status on a given date - forum topic by voleary

$
0
0

I have a table (status_moves) which logs each time a record changes status. It looks like this:
[db.stage_moves]

_date

account_id

old_value

new_value

5/21/2014

400

B

C

5/31/2014

400

C

A

6/1/2014

300

C

B

6/4/2014

400

A

C

7/1/2014

300

B

A

 
I need to write a query to determine what stage a a particular account_id was in on a particular date. For example,
For the question :"In what status was Account_id 400 on June 21, 2014?"
The Answer should be "C", as the most recent "new_value" prior to June 21 was "C".
 
How can I write a query to get the end result to look like this:

_date

account_id

account_status_on_date

6/21/2014

400

C

I believe I need to use max or min function but am unsure of where to start.

Forums: 

Determine status on a given date - response (1) by voleary

$
0
0

This is the format of the [db.stage_moves] table:
_date             account_id        old_value        new_value
5/21/2014          400               B                    C
5/31/2014          400               C                    A
6/01/2014          300               C                    B
6/04/2014          400               A                    C
7/01/2014          300               B                    A
 

Determine status on a given date - response (2) by voleary

$
0
0

And this is how I would want to see the result to determine status on June 21, 2014:
_date            account_id          account_status_on_date
6/21/2014          400                        C 

New to Teradata from T-SQL - forum topic by bree_l

$
0
0

Good Morning All,
I've just changed roles. I've got about 4 years experience with MS SQL Server (T-SQL) and my new role uses Teradata.
I'm sure I'm not the first person who has made this change, and was wondering if anyone has a cheat sheet for common functions and operators translated from T-SQL to TD. (As I'm sure everything I could do in MSSMS, I can do in TD Sql Assistant  as far as cutting code)
I've started noticing things in TD are quite different (working with dates in example). Doing a simple DATEDIFF calculation seems very complex in TD (though, I could just be reading poor forum posts).
From my reading, It's also become apparent that it isn't possible to declare variables ? i.e.
DECLARE @Startdate DATE = '2014-08-04';
DECLARE @Enddate DATE = '2014-08-10';
I typically like to use dates in my where clause to limit my data. I read one solution was to create temporary tables and join to them to achieve the same as a declare statement? Is this correct?
Any advice would be ablsolutely terrific.

Forums: 

Partition effectiveness - response (1) by Raja_KT

$
0
0

 

This is my opinion. I make partition to achieve speed and a goal: I will count the partitions. This is just example:

SELECT RANGE_N( EFF_END_DT  BETWEEN DATE '2012-12-31' AND DATE '9999-12-31' EACH INTERVAL '7' DAY , NO RANGE, UNKNOWN) partitions

COUNT(*) AS cnt,

FROM table1

GROUP BY partitions

;

 

Grouping older ranges with less finer say

PARTITION BY RANGE_N (order_date BETWEEN DATE '2012-12-31' 

AND DATE '2013-12-31'

EACH INTERVAL '3' MONTH,

DATE '2013-12-31'

AND DATE '2014-06-30'

EACH INTERVAL '7' DAY,

.........  

 

SELECT *

FROM table1

WHERE your_date BETWEEN DATE '.....aaaa-12-31...' AND DATE '.....bbbb-12-31';

Determine status on a given date - response (3) by cmedved

$
0
0

I used the following to recreate your example:
 

CREATE VOLATILE TABLE vt_stage_moves
	, NO FALLBACK
	, NO JOURNAL
(
	_date DATE,
	account_id INTEGER,
	oldValue CHAR(1),
	newValue CHAR(1)
) PRIMARY INDEX (_date,account_id)
ON COMMIT PRESERVE ROWS;

insert into vt_stage_moves values('2014-05-21',400,'B','C');
insert into vt_stage_moves values('2014-05-31',400,'C','A');
insert into vt_stage_moves values('2014-06-01',300,'C','B');
insert into vt_stage_moves values('2014-06-04',400,'A','C');
insert into vt_stage_moves values('2014-07-01',300,'B','A');

 
I would personally feel most comfortable doing this with Ordered Analytic Functions.
 

SELECT '2014-06-21' AS _date,account_id,newValue AS account_status_on_date
FROM vt_stage_moves st
WHERE st._date <= '2014-06-21'
AND st.account_id = 400
QUALIFY ROW_NUMBER() OVER (ORDER BY st._date DESC) = 1;

 
Now... you'll note that I had to manually hard code the date... this query would work best by creating a macro for it, where you can just use variables.
 
The basic idea of the query is:
1. Pick all of the dates less than the specified date.
2. Pick the highest date out of the dates from (1).
 
ROW_NUMBER() simply assigns a number to the row based on the ORDER BY in the OVER clause. QUALIFY is the clause for filtering based on ordered analytic functions (much like you use the HAVING clause for aggregation functions). There are MANY other ways to use ordered analytic functions... this is just one use case.

Incremental Backup in Teradata Environment - forum topic by Teradata_User1

$
0
0

Hello Experts,
I am new to Teradata, Kindly let me know how we can achieve Incremental backup in our TD environment.
I know we can do it by using PPI and Journals (Before/After Image) but these are time & resourse consuming process. So I dont want to go with these options.
Do we have any other settings in teradata or Netbackup server end to achieve this incremental backup ?
We have installed TARA software in our environment and it is linked with our Netbackup master server. 
Everytime we take full backup after every 15days but this time we need to check incremental backup.
Kindly help us ASAP.
Regards,
Teradata_User1

Forums: 

Determine status on a given date - response (4) by voleary

$
0
0

Thank you cmedved! This makes a ton of sense. I also agree with your logic regarding the macro.
 
Moreover, my bigger goal is to create a table which has all dates up to today, the account_id, and the stage on that day.
 
I'm going to combine the technique you've suggested in conjunction with a join I am doing to a dates table and will post my findings/results. 
 
Appreciate your help!
 
 

Varchar to Timestamp(6) conversion - forum topic by OM186000

$
0
0

My customer has loaded a TD test table with a date & time column that looks like this:
Column:      XXXXXX   varchar(23) 
Data:
7/31/2014 9\:20\:03 AM
8/4/2014 8\:23\:15 AM
12/6/2014 2\:31\:07 PM 
 
What is the quickest/easiest way to convert the data to TIMESTAMP(6),  if possible at all ?   
The output should look something like    YYYY-MM-DD HH:MM:SS.ssssss   
 
Thanks
Orlando

Forums: 

QUALIFY ... OVER (PARTITION BY ...) phrase - response (6) by Chandan

How to limit rows to only those where there are duplicates of a specific column? - response (8) by Chandan

$
0
0

Hi Dieter,
Can you please help for below requirement.
I have below records in my table,

  ACCT    ID    CD     

1)  123   2500   AB1         

2)  123   24386  AB2

3)  123   2500   AB3

4)  123   2500   AB4

5)  123   2500   AB5

6)  123   24386  AB6

7)  123   2500   AB7

8)  123   2500   AB8

 

order by CD after then IF my ID 24386 is in between 2500(2 nd row &6 rows are in between ) then i need to take the cd of next rows till i found another 24386.

 

expected result for column  DER_CD

 

  ACCT    ID    CD     DER_CD

1)  123   2500   AB1   AB1       

3)  123   2500   AB3   AB3

4)  123   2500   AB4   AB3

5)  123   2500   AB5   AB3

7)  123   2500   AB7   AB7

8)  123   2500   AB8   AB7

 

Please help on that

 

Thanks,

Chandan

 

Invalid Timestamp - forum topic by bhartiya007

$
0
0

Hi Gurus,

 

I have a requirement where i need to know what all sessions run between a particular timestamp which is input by user. The query below is throwing invalid timestamp error.

My database version is :Teradata 14.10.0104  14.10.01.04

 

 

SEL J.WKFLW_NAME, J.SESSION_NAME, J.STRT_TM,J.END_TM

FROM G_D_P_BV.G_D_ETL_JOB_RUN_DTL J

INNER JOIN

G_D_P_BULK_V.CDR_G_WORKFLOW_RUN_DETAIL W

ON J.WKFLW_NAME=W.WORKFLOW_NAME

where

J.WKFLW_NAME='wflw_G_TC_STAGE'

and

CAST(J.STRT_TM AS timestamp(6) FORMAT 'MM/DD/YYYYBHH:MI:SS') 

BETWEEN 

 

CAST('?workflow_start_time' AS timestamp(6) FORMAT 'MM/DD/YYYYBHH:MI:SS')

AND

CAST('?workflow_end_time' AS timestamp(6) FORMAT 'MM/DD/YYYYBHH:MI:SS')

group by 1,2,3,4

 

Regards,

Amit

Forums: 

Unicode data - forum topic by reddyrajendra2014

$
0
0

Hi , can some one help me to find out sol...
 
How to determine one column has unocode data or not ?
is there any function avail??
 
Reason :: I have one table , it has huge data. One column defined as Unicode . Now we need to chk data of that column . If that column wont contain unicode values we will change to LATIN.
Thanks in Adv..

Forums: 

Transpose columns to row in a single query - forum topic by Moutusi


Delete duplicate in a single query - forum topic by Moutusi

Unicode data - response (1) by CarlosAL

$
0
0

You may take a look at TERADATA FUNCTION TRANSLATE_CHK()
HTH.
Cheers.
Carlos.

Delete duplicate in a single query - response (1) by reddyrajendra2014

$
0
0

sel
A,B,C
FROM
table
group by A,B,C .
 
 

Unicode data - response (2) by reddyrajendra2014

$
0
0

Carlosal,
I think TRANSLATE_CHK() will do chk on un translatable char's .
I would like to determine wether unicode data is present or not ?.
I am not bothering about untranslatable chars.
Do we have any other function to determine it.

Unicode data - response (3) by CarlosAL

$
0
0

If the result of TRANSLATE_CHK() is 0 then all the characters can be translated without error (all the characters are "latin" -note the double quotes-)
HTH.
Cheers.
Carlos.

Viewing all 14773 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>