teradata

Teradata SQL how to transfer “by date” to by “date range”?

风流意气都作罢 提交于 2019-12-11 19:14:38
问题 I have 600 Million rows as table 1 below. In Teradata SQL how to transfer "by date" to by "date range"? +-----------+-------+------------+----------+ | ProductID | Store | Trans_Date | Cost_Amt | +-----------+-------+------------+----------+ | 20202 | 2320 | 2018-01-02 | $9.23 | | 20202 | 2320 | 2018-01-03 | $9.23 | | 20202 | 2320 | 2018-01-04 | $9.23 | | 20202 | 2320 | 2018-01-05 | $9.38 | | 20202 | 2320 | 2018-01-06 | $9.38 | | 20202 | 2320 | 2018-01-07 | $9.38 | | 20202 | 2320 | 2018-01-08

Where are Teradata header files downloaded from? (DBD::Teradata build)

旧巷老猫 提交于 2019-12-11 18:48:23
问题 I am attempting to build the Perl DBD::Teradata DBI driver on 64 bit linux. However, I do not have the header files necessary to do so. According to the documentation (http://www.presicient.com/tdatdbd/), the following files are required: parcel.h dbcarea.h coperr.h coptypes.h I've spent hours scouring Teradata's site and the internet at large with no success. I saw mention of a CLIv2 developer's kit, but could not locate this either. Could anyone point me to where I can get these files? I

Delete duplicates GPS coordinates in column in each row

我只是一个虾纸丫 提交于 2019-12-11 18:42:49
问题 I have a column with gps coordinates, in each row a set of geo-polygon coordinates. Most lines have duplicate gps coordinates (complete coincidence of longitude and latitude in one column). Example: MULTIPOLYGON 23.453411011874813 41.74245395132344 23.453972640029299 41.74214208390741 23.453977029220994 41.741827739090233 23.454523642352295 41.741515869012523 23.441100249526403 41.741203996333724 23.441661846243466 41.740892121053918 23.456223434003668 41.74058024317317 23.441661846243466 41

Teradata MAX function

ぃ、小莉子 提交于 2019-12-11 18:34:08
问题 Which row will be return if we use following function? MAX (NAME) Where we have following two rows in name column 1 ABC 2 ABC 回答1: Neither. An aggregate will be returned that is not tied to either row, but rather the Max(Name) value, which will obviously have to be ABC as it's the only value available: CREATE VOLATILE TABLE test ( f1 INTEGER, f2 CHAR(3) ) PRIMARY INDEX (f1) ON COMMIT PRESERVE ROWS; INSERT INTO test VALUES (1, 'ABC'); INSERT INTO test VALUES (2, 'ABC'); SELECT MAX(f2) FROM

Find columns with NULL values in Teradata

一笑奈何 提交于 2019-12-11 16:16:36
问题 I would like to find the columns in a table that has a null value in it. Is there a system table that have that information? 回答1: To find columns where "null" values are allowed try... select * from dbc.columns where databasename = 'your_db_name' and tablename = 'your_table_name' and Nullable = 'Y' then to identify the specific rows w/ null values, take the "ColumnName" from the previous result set and run queries to identify results... perhaps throw them in a volatile table if you want to

BTEQ: Save Teradata error in logfile

一曲冷凌霜 提交于 2019-12-11 13:07:05
问题 My goal is to automate a deployment of SQL scripts to Teradata via BTEQ. So far my script is working. However, I would like to generate a log file where possible failures are captured. .LOGON tdserver/username,pw .EXPORT file=\logfile.txt; .run file = \Desktop\test\test.sql; .LOGOFF .EXIT My SQL script will create a VIEW. When this view for example already exists I see an error in the BTEQ command window: *** Failure 3804 View 'ViewName' already exists. I would like to have this TD Message in

Need to skip line containing “Value Error”

大憨熊 提交于 2019-12-11 12:56:45
问题 I'm trying to extract some legacy data from a Teradata server, but some of the records contain weird characters that don't register in python, such as "U+ffffffc2". Currently, I'm using pyodbc to extract the data from Teradata Placing the results into a numpy array (because when I put it directly into pandas, It interprets all of the columns as a single column of type string) Then I turn the numpy array into a pandas dataframe to change things like Decimal("09809") and Date("2015,11,14") into

How to create a trigger for on update timestamp in Teradata table?

不羁岁月 提交于 2019-12-11 12:52:52
问题 I am using Teradata 14.00 I have a table with columns (id, name,city,mytime) in Teradata 14.00. If we update the name, the timestamp in 'mytime' column should be updated automatically, without having to specify it in the Update statement. How to use a trigger for this. Any suggestions. Thanks in advance 回答1: Here is a very good article http://teradatafaqs.blogspot.in/p/tutorial.html for studying triggers. For your ease here is the step by step creating of the trigger. Sample table Temp Table

INTO clause is not allowed error

自闭症网瘾萝莉.ら 提交于 2019-12-11 12:29:55
问题 I'm trying a simple SQL select into statement on teradata tables, and following the syntax I found here. The statement is the following: select * into DBNAME.account_backup from DBNAME.account; When I run this code I get the following error: SELECT Failed. 3706: Syntax error: INTO clause is not allowed The two tables have precisely the same format (I copied the SQL which created the first table and pasted it to create the second, changing only the name). Any ideas? Much gratitude 回答1: SELECT

Teradata SQL tuning with Sum and other aggregate functions

蹲街弑〆低调 提交于 2019-12-11 12:21:41
问题 I have a query like sel tb1.col1, tb4.col2, (case WHEN t4.col4 in (<IN LIST with more than 1000 values!>) then T4.Col7 Else "Flag" ) as "Dcol1", Sum ( tb3.col1), sum (tb3.col2 ), sum (tb2.col4) etc from tb1 left outer join tb2 <condition> LOJ tb3 <conditions> where tb1 condition and tb2 condition and tb3 condition group by ( case <condition> , colx.tb2,coly.tb1 Problem is TB3 and TB4 are HUGE fact table. The PI of the fact table is NOT included in the joins or Queries here. What I have done