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

New to Teradata and SQL - forum topic by stubag13

$
0
0

Hi Guys
I am new to working with Teradata Systems and SQL and would like some guidance on where to start and how I should/could get started on the basics, like creating tables, loading data etc and what utilities I use.
Can anyone recommend some good resources, videos or materials that I can read or look at to get me started. The simpler the better :).
The tools I have so far on my laptop are Teradata Studio Express and Putty. Im assuming these are using for talking to the Teradata system. 
Apologies if these are very basic questions but this is all completely new to me.
Thanks 
 
Stuart

Forums: 

New to Teradata and SQL - response (1) by Raja_KT

$
0
0

You can see this link: http://www.info.teradata.com/ . In it, you can find "Teradata Database, Tools and Utilities Release". You can choose which version you are in(13.10,14,....). I suggest you  start with introduction, then step by step with others like "SQL Data Definition Language Detailed Topics" so that you can see the real beauty, how it is different from other DBs.
 

Same old Untranslatable character - forum topic by sri99iitm

$
0
0

Hello , 
Using below statment, I found a untranslatable character in a VARCHAR column
SELECT COL FROM TABLE WHERE TRANSLATE_CHK (COL USING LATIN_TO_UNICODE)<>0;
 'XXXX □ YYYY'
Character is the little square as  shown above. 
I cannot use update table, cannot touch source table, only option is SELECT and get output as  'XXXX YYYY' . 
I tried oreplace,otranslate  in SELECT , which says "Failed. 6706:  The string contains an untranslatable character. "
Any inputs 
 
Regards,
Sri

Forums: 

Same old Untranslatable character - response (1) by VandeBergB

$
0
0

you can use the output of the translate_chk function in combination with substring to trim out the errant character in a select statement.
select substring(col from 1 to (translate_chk(col using latin_to_unicode) -1))||'XXXX YYYY'||substring(col from (translate_chk(col using latin_to_unicode)+1) to char_length(col))
--no guarantee the parenthesis match in the example, but it illustrates the concept 

Date data type - response (1) by VandeBergB

$
0
0

Would you be so thoughtful as to post the DDL?

Complex analytical query help - response (7) by jnbalaji

$
0
0

Hi dieter,
Some change in requirement.
Table structure has changed. reporting columns are static.
They are from Jan -15 to Dec - 17.

CREATE TABLE subscriber_feature

(SUB_ID INTEGER,  -- subscriber id

feature_code VARCHAR(20) -- feature code

feature_add_dttm DATE, --add dttm

feature_remove_dttm DATE,  -remove dttm

feature_cancel_dttm DATE,  -- cancel dttm

Sub_stat_cd CHAR(1))  - ex value 'a' - ACTIVE, 'c' - CANCEL  etc

PRIMARY INDEX(sub_id);

INSERT INTO  subscriber_feature VALUES(123,'Code','2015-01-15','2015-03-20', NULL,'A' );
INSERT INTO subscriber_feature VALUES(234,'Code','2015-01-20','2015-04-05', '2015-05-02','C');
INSERT INTO subscriber_feature VALUES(345,'Code','2015-02-05','2015-04-15',NULL,'A');
INSERT INTO  subscriber_feature VALUES(456,'Code','2015-01-25',NULL,2015-03-21,'C');
INSERT INTO  subscriber_feature VALUES(456, 'Code','2015-04-20','2015/05/20',NULL,'A' );
INSERT INTO subscriber_feature VALUES(567, 'Code','2015-02-10','2015-02-25',NULL,'A');
INSERT INTO  subscriber_feature VALUES(678, 'Code','2015-03-10',NULL,NULL,'A');
One problem in that. If the customer removed feature or cancel subscription in same month he added, then end_dt will give previous month end date.
So count may go wrong for this scenario.

We are considering 6 million records. Can we introduce some table to store intermediate result in between to make the query performance better. If so, what format it should be?
Looking forward for your help.

Thanks

Using DISTINCT with Ordered Analytic Functions and Dates - forum topic by vbdcb

$
0
0

I have run into a perplexing little problem. I know how to work around it, but want to understand the reason it is occuring.

 

 

 

When I use the FIRST_VALUE function on a date as below, it returns two rows:

SELECT  
	l.Id	ID, 
	FIRST_VALUE(t.LASTMODIFIEDDATE) OVER(PARTITION BY l.ID ORDER BY t.LASTMODIFIEDDATE)	First_Contacted

 

I only want to return a single row, so I add DISTINCT to the code:

SELECT DISTINCT
	l.Id	ID, 
	FIRST_VALUE(t.LASTMODIFIEDDATE) OVER(PARTITION BY l.ID ORDER BY t.LASTMODIFIEDDATE)	First_Contacted

This returns the error: Failed [5407 : HY000] Invalid operation for DateTime or Interval. 

Why????

 

 

Forums: 

Complex analytical query help - response (8) by jnbalaji

$
0
0

Hi,
"One problem in that. If the customer removed feature or cancel subscription in same month he added, then end_dt will give previous month end date.
So count may go wrong for this scenario."
Above is not a problem as we gre grouping on start date everything works fine. My bad. But as i said huge no of input is the problem. Experts want  to break this process in to two with intermediate table.
 
thanks.


Complex analytical query help - response (9) by dnoeth

$
0
0

What's the performance of the current query? If it's good enough there's no need to use additional tables (besides maybe one permanent table with 36 rows for each 1st of month instead of a query on the calendar)
Can you show the explain?

write SQL UDF in Teradata - response (7) by vishaman

$
0
0

Hi 
Can  anybody help me write an SQL UDF to add days to a date ? 
It simply needs to be accepting a date and a number and adding them together to return another date
Please help .
Regards
Vishnu 

write SQL UDF in Teradata - response (8) by tomnolan

$
0
0
REPLACE FUNCTION ADD_DAYS(p1 DATE, p2 INTEGER)
RETURNS DATE
LANGUAGE SQL
CONTAINS SQL
DETERMINISTIC
SQL SECURITY DEFINER
COLLATION INVOKER
INLINE TYPE 1
RETURN p1 + CAST(p2 AS INTERVAL DAY) ;

 

Special Characters in Teradata - response (18) by dbsar

$
0
0

Hi,
I am using otranslate as below syntax and it gives me error as 6709: The string contains untranstable character.
otranslate(Coalesce(Contractor_name,''),':','') new_name
Can anyone help?
Thank you!

write SQL UDF in Teradata - response (9) by vishaman

$
0
0

That worked like a charm , tomnolan ... Many thanks to you !!!!

(DBQL- DBC.Qrylog ) How to convert ELAPSEDTIME (HH:MM:SS.00) to Seconds - forum topic by Sandeepyadav

$
0
0

Hi All,
 
just want to conver the elapsedtime (H:MM:SS.00) to Seconds. DBC.Qrylog has one column Elapsedtime but i want this value in seconds only.
 
Please suggest .

Forums: 

Question regarding RIs - forum topic by nick2408

$
0
0

Hi all
I have been trying to do some test cases and see that when a normal FK is created, we get a _0 table name as well. I have reviewed other discussions on the forum related to this topic and came to know that this table is created when the chck is performed by database and is called a Hard RI.
While using 'with no chck option' (soft RI) doesn't create the _0 table, I was curious to know why does using 'with check option' doesnt create _0 table. As evident from my test cases below, with check option does return error but the error code is different.
error 2700 in case of hard RI and 3513 in case of with check option
Is using with check option same as enforcing a hard RI?
Any help in making me understand this behaviour would be great.
test cases:

Failure 3513 RI violation

 

 

Failure 2700 Referential constraint violation: invalid Foreign Key value.

 

 

ct t1(x1 int not null,x2 int) primary index(x1);

alter table t1 add primary key(x1);

ins into t1(1,2);

ins into t1(2,3);

 

ct t2(y1 int, y2 int);

alter table t2 add foreign key(y1) references t1(x1);

 

help database test;

 

 *** Help information returned. 3 rows.

 *** Total elapsed time was 1 second.

 

Table/View/Macro name          Kind Comment

------------------------------ ---- ---------------------------------------

t1                             T    ?

t2                             T    ?

T2_0                           T    ?

 

ins into t2(4,5);

 *** Failure 2700 Referential constraint violation: invalid Foreign Key value.

 

drop table t2;

ct t2(y1 int, y2 int);

alter table t2 add foreign key(y1) references with check option t1(x1);

 

ins into t2(5,4);

 *** Failure 3513 RI violation.

Forums: 

Remove the first 4 characters in a string - response (4) by Dvya

$
0
0

I have table with follwing data
EMP_ID EMP_ADDR
11010 Divya is from bangalore
12034 Suresh from chennai
150567 from mumbai
12345 Sadic is working from delhi
I have to extract the EMP_ADDR like starting from "FROM" till end
Sample O/P
EMP_ID EMP_ADDR
11010 from bangalore
12034 from chennai
150567 mumbai
12345 from delhi
Can some one please help me to get required out put

Looping in teradata - forum topic by mnagara

$
0
0

Hi Guys,
I need some info on looping in Teradata with below requirement. Anny help will be appriciated. Thanks in advance,
 
source field is string which is having below format,
[{"createdBy":null,"couponNo":1234,"couponAmount":1345,"updatedBy":mike},{"couponNo":7654,"couponAmount":67654,"updatedBy":sam},{"ItemNo":8765,"createdBy":null,"couponNo":7654,"couponAmount":9878,"updatedBy":john}]
 
We have to split above field as below,
row no       Field1                         Field2                
1             "couponNo":1234       "couponAmount":1345
2             "couponNo":7654       "couponAmount":67654
3             "couponNo":7654       "couponAmount":9878
 
 

Forums: 

Join on different datatype - forum topic by KVB

$
0
0

Hi All,
I hgave a table of huge size say 750 GB contains trillions of records.Daily we process millions of records.There is a join on INTEGER and 36 character alpha numeric key.Could you please let me know will there be any impact on this?
 
Regards
KVB

Forums: 

Querying a partitioned table - forum topic by KVB

$
0
0

Suppose there is less data in an already date partitioned table. Like,if we only have the last 3 months of data in the table will it perform faster during queries. When querying the tables they should both have the same partition on date and be queried with the same date range, which should be a sub selection of all the available dates-perhaps 1 week?
 
Thanks
KVB

Forums: 

(DBQL- DBC.Qrylog ) How to convert ELAPSEDTIME (HH:MM:SS.00) to Seconds - response (1) by Raja_KT

$
0
0

There may be better ways. However, I am thinking this way:
SELECT EXTRACT (hour FROM '13:36:15.5') *3600 a,EXTRACT (minute FROM '13:36:15.5') *60 b, EXTRACT (second FROM '13:36:15.5') c, a+b+c

Viewing all 14773 articles
Browse latest View live