teradata

Connect R and Teradata using JDBC

痴心易碎 提交于 2019-11-30 18:29:46
问题 I´m trying to connect R and Teradata using RJDBC. I´ve found this link that has an example using mysql, but i´m nos sure how to do the same with teradata. library(RJDBC) drv <- JDBC("com.mysql.jdbc.Driver", "/etc/jdbc/mysql-connector-java-3.1.14-bin.jar", identifier.quote="`") conn <- dbConnect(drv, "jdbc:mysql://localhost/test", "user", "pwd") I´ve downloaded this driver: http://downloads.teradata.com/download/connectivity/jdbc-driver But i´m not sure where i should reference the directory.

LISTAGG equivalent in Teradata

ε祈祈猫儿з 提交于 2019-11-30 16:10:00
Is there any equivalent of Listagg function of oracle in teradata. With recursive is an option I have tried, but wanted something other than. Thanks Aritra If Teradata's XML-services are installed (default since 14.10?) there's a function named XMLAGG, e.g. SELECT DatabaseName, TABLENAME, TRIM(TRAILING ',' FROM (XMLAGG(TRIM(Columnname)|| ',' ORDER BY ColumnId) (VARCHAR(10000)))) FROM dbc.ColumnsV WHERE databasename = 'dbc' AND TABLENAME = 'ColumnsV' GROUP BY 1,2 来源: https://stackoverflow.com/questions/29510654/listagg-equivalent-in-teradata

SQL Challenge/Puzzle: How to merge nested ranges?

有些话、适合烂在心里 提交于 2019-11-30 05:41:18
问题 This challenge is based on a real life use-case involving IP ranges. The solution I came with is based on the stack trace challenge I've presented previously. Each range start is treated as a PUSH operation and each range end + 1 is treated as a POP operation. The Challenge We have a data set of ranges where each range has a starting point, ending point and a value. create table ranges ( range_start int not null ,range_end int not null ,range_val char(1) not null ) ; A range can contain

LISTAGG equivalent in Teradata

倖福魔咒の 提交于 2019-11-30 00:08:28
问题 Is there any equivalent of Listagg function of oracle in teradata. With recursive is an option I have tried, but wanted something other than. Thanks Aritra 回答1: If Teradata's XML-services are installed (default since 14.10?) there's a function named XMLAGG, e.g. SELECT DatabaseName, TABLENAME, TRIM(TRAILING ',' FROM (XMLAGG(TRIM(Columnname)|| ',' ORDER BY ColumnId) (VARCHAR(10000)))) FROM dbc.ColumnsV WHERE databasename = 'dbc' AND TABLENAME = 'ColumnsV' GROUP BY 1,2 来源: https://stackoverflow

Accomplish pivot in teradata sql

大憨熊 提交于 2019-11-29 23:09:05
问题 Say I have a query that returns values like this: id type value aaa 1a 10 aaa 1b 20 aaa 1c 7 bbb 2a 10 bbb 1a 5 There are > 50 million rows and 240 possible "types". I want to make a pivot where there is one row for each id and each type is it's own column: id 1a 1b 1c 2a aaa 10 20 7 bbb 5 10 I can do this in SQL server but I don't know how to do it in Teradata. There are too many columns for me to make CASE statements. However, each distinct type is in a table field, if that's any help. 回答1:

JOIN versus EXISTS performance

谁说胖子不能爱 提交于 2019-11-29 10:27:45
Generally speaking, is there a performance difference between using a JOIN to select rows versus an EXISTS where clause? Searching various Q&A web sites suggests that a join is more efficient, but I recall learning a long time ago that EXISTS was better in Teradata. I do see other SO answers, like this and this , but my question is specific to Teradata. For example, consider these two queries, which return identical results: select svc.ltv_scr, count(*) as freq from MY_BASE_TABLE svc join MY_TARGET_TABLE x on x.srv_accs_id=svc.srv_accs_id group by 1 order by 1 -and- select svc.ltv_scr, count(*

Retrieving column and other metadata information in Teradata

岁酱吖の 提交于 2019-11-29 10:20:56
I have a half dozen views in SQL Server that I need to replicate in Teradata, but I haven't been able to find the TD equivalent of the SQL metadata tables. I'd like to replicate the following functionality (which I assume is fairly self-explainatory): select table_name, column_id ordinal_position, column_name, data_type, char_length char_max_length, data_precision numeric_precision, data_scale numeric_scale from user_tab_columns select name as FUNCTION_NAME from sys.objects where type_desc='SQL_SCALAR_FUNCTION' select TABLE_NAME as VIEW_NAME from INFORMATION_SCHEMA.VIEWS I'd also like to know

How to calculate moving sum with reset based on condition in teradata SQL?

浪尽此生 提交于 2019-11-29 06:58:17
I have this data and I want to sum the field USAGE_FLAG but reset when it drops to 0 or moves to a new ID keeping the dataset ordered by SU_ID and WEEK : SU_ID WEEK USAGE_FLAG 100 1 0 100 2 7 100 3 7 100 4 0 101 1 0 101 2 7 101 3 0 101 4 7 102 1 7 102 2 7 102 3 7 102 4 0 So I want to create this table: SU_ID WEEK USAGE_FLAG SUM 100 1 0 0 100 2 7 7 100 3 7 14 100 4 0 0 101 1 0 0 101 2 7 7 101 3 0 0 101 4 7 7 102 1 7 7 102 2 7 14 102 3 7 21 102 4 0 0 I have tried the MSUM() function using GROUP BY but it won't keep the order I want above. It groups the 7's and the week numbers together which I

teradata sql pivot multiple occurrences into additional columns

我只是一个虾纸丫 提交于 2019-11-28 23:49:23
I have something like this: ID Result 1 value1 2 value1 2 value2 3 value1 4 value1 4 value2 4 value3 And I'd like to return something like this: ID Result1 Result2 Result3 1 value1 2 value1 value2 3 value1 4 value1 value2 value3 I've searched on pivots and concats and breaks and I just can't find a simple, sensible solution. TIA Unfortunately Teradata doesn't have a PIVOT function but you can use an aggregate function with a CASE expression to get the result. select id, max(case when seq =1 then result end) result1, max(case when seq =2 then result end) result2, max(case when seq =3 then

Connecting Python with Teradata using Teradata module

最后都变了- 提交于 2019-11-28 18:28:25
I have installed python 2.7.0 and Teradata module on Windows 7. I am not able to connect and query TD from python. pip install Teradata Now I want to import teradata module in my source code and perform operations like - Firing queries to teradata and get result set. Check if connection is made to teradata. Please help me writing code for the same as I am new to Python and there is no information available with me to connect to teradata. There are a number of ways to connect to Teradata and export table to Pandas. Here are three: Using teradata module # You can install teradata via PIP: pip