teradata

Teradata REGEXP_SPLIT_TO_TABLE Input Parameter

邮差的信 提交于 2019-12-13 07:04:21
问题 I'd like to be able to define an input parameter in a CTE and then use it within a REGEXP_SPLIT_TO_TABLE function, like so: WITH PARAMS (INPUT_PARAMS) AS (SELECT '?InputParams' AS INPUT_PARAMS ) SELECT TEST_TABLE.SPLIT_PARAMS FROM TABLE (REGEXP_SPLIT_TO_TABLE(1, PARAMS.INPUT_PARAMS, '\|', 'i') RETURNS (outkey INTEGER, TOKENNUM INTEGER, SPLIT_PARAMS VARCHAR(8192) CHARACTER SET UNICODE)) AS TEST_TABLE CROSS JOIN PARAMS However this yields the following error: SELECT Failed. [3706] Syntax error:

concatenating the two column values of different rows into one in teradata

空扰寡人 提交于 2019-12-13 05:58:16
问题 I have table with the below data in teradata database cstmr_id | name 1 | aaaaaa 1 | bbbbbb 2 | cccccc 2 | dddddd I want the output to be like 1 | aaaaaa,bbbbbb 2 | cccccc,dddddd The output should be written to another table. All this needs to be done in teradata. Thanks in Advance, Nikhila 回答1: What's your Teradata release? Are XML services installed? SELECT cstmr_id, RTRIM(XMLAGG(name || ',' ORDER BY name ) (VARCHAR(1000)),',') FROM tab GROUP BY 1 来源: https://stackoverflow.com/questions

Recursive Teradata Query

China☆狼群 提交于 2019-12-13 05:49:28
问题 I'm trying to query the below table into a consolidated and sorted list, such as: Beginning list: GROUP_ID MY_RANK EMP_NAME 1 1 Dan 1 2 Bob 1 4 Chris 1 3 Steve 1 5 Cal 2 1 Britt 2 2 Babs 2 3 Beth 3 1 Vlad 3 3 Eric 3 2 Mike Query Result: 1 Dan, Bob, Steve, Chris, Cal 2 Britt, Babs, Beth 3 Vlad, Mike, Eric It needs to use a recursive query because the list is much longer. Also, I have to sort by my_rank to get them in sequential order. Thanks in advance. I've tried about 10 examples found on

Teradata - Comparing Varchar to decimal

五迷三道 提交于 2019-12-13 05:09:36
问题 I am very new to Teradata and SQL in general. I need to create a table by combining data from three tables. I was able to successfully join two of them. I am not able to write the joining condition for the third table properly. Here is the code: select s.cola, s.colb, t.colc, t.cold, u.cole, u.colf, u.colg, u.colh, u.coli, u.colj, u.colk, u.coll from table1 s inner join table2 t on s.colb = t.colc inner join table3 u on t.cold = cast(u.colm as decimal) order by 3 where substr(cast(s.cola as

Run query on sql server through teradata and store result in teradata

我们两清 提交于 2019-12-13 04:43:37
问题 I have one table in SQL server and 5 tables in Teradata.I want to join those 5 table in teradata with sql server table and store result in Teradata table. I have sql server name but i dont know how to simultaneously run a query both on sql server and teradata. i want to do this: sql server table query Select distinct store from store_Desc teradata tables: select cmp_id,state,sde from xyz where store in ( select distinct store from sql server table) 回答1: You can create a table (or a volatile

Taking Sample in SQL Query

让人想犯罪 __ 提交于 2019-12-13 03:59:26
问题 I'm working on a problem which is something like this : I have a table with many columns but major are DepartmentId and EmployeeIds Employee Ids Department Ids ------------------------------ A 1 B 1 C 1 D 1 AA 2 BB 2 CC 2 A1 3 B1 3 C1 3 D1 3 I want to write a SQL query such that I take out 2 sample EmployeeIds for each DepartmentID . like Employee Id Dept Ids B 1 C 1 AA 2 CC 2 D1 3 A1 3 Currently I am writing the query, select EmployeeId, DeptIds, count(*) from table_name group by 1,2 sample

Best way to compare contents of two tables in Teradata?

有些话、适合烂在心里 提交于 2019-12-13 03:52:11
问题 When you need to compare two tables to see what the differences are, are there any tools or shortcuts you use, or do you handcode the SQL to compare the two tables? Basically the core features of a product like Red Gate SQL Data Compare (schemas for my tables typically always match). Background: In my SQL Server environment, I created a stored procedure which inspects the metadata of the two tables/views, creates a query (as dynamic sql) which joins the two tables on the specified key columns

ExceptionInInitializer Error while Reading Data from teradata table using Spark

守給你的承諾、 提交于 2019-12-13 03:45:47
问题 I am using the below code to read data from teradata but getting error val jdbcDF = spark.read .format("jdbc") .option("url",s"jdbc:teradata://${TeradataDBHost}/database=${TeradataDBDatabase}") .option("dbtable", TeradataDBDatabase+"."+TeradataDBTable) .option("driver","com.teradata.jdbc.TeraDriver") .option("user", TeradataDBUsername) .option("password", TeradataDBPassword) .load() Error Stack Trace Exception in thread "main" java.lang.ExceptionInInitializerError at com.teradata.jdbc.jdbc

Transferring Millions of rows from teradata to mySQL

徘徊边缘 提交于 2019-12-13 03:38:31
问题 I have to transfer around 5 million rows of data from Teradata to MySQL. Can anyone please suggest me the fastest way to do this over the network, without using the filesystem. I am new to Teradata and MySQL. I want to run this transfer as a batch job on weekly basis, so I am looking for the solution which can be fully automated. Any suggestions or hints will be greatly appreciated. I have already written the code using JDBC to get the records from the Teradata and insert them into the MySQL.

Store the result of a select statement within a stored procedure

一世执手 提交于 2019-12-13 03:34:09
问题 This is a Teradata v14 specific question. How to store the result of a query within a stored procedure for further processing. Options I have looked at: volatile temporary table - but that needs to be created prior to stored procedure derived table - but it only holds the result for the duration of one query The result needs to be available for the duration of the stored procedure. Are there any other options? Update 16 June 2014: Based on the answers and comments it seems that volatile table