teradata

Conversion of Teradata sql to MYSQL sql

∥☆過路亽.° 提交于 2020-06-29 05:17:29
问题 I want to convert Teradata query into MYSQL query. Datatype of START_TIME AND END_TIME is TIMESTAMP(6) Teradata query:- select START_TIME,END_TIME, (EXTRACT(DAY FROM (END_TIME - START_TIME DAY(4) TO SECOND)) * 86400) from base.xyz Result is like:- **START_TIME, END_TIME, CALCULATED_FIELD** 9/15/2017 16:22:52.000000 9/19/2017 15:14:02.000000 259,200 7/26/2014 07:00:04.000000 7/28/2014 12:55:55.000000 172,800 6/8/2018 16:59:19.000000 6/11/2018 09:56:23.000000 172,800 10/6/2017 17:52:06.000000

Percentage of cases within a group by year

大兔子大兔子 提交于 2020-06-27 06:17:41
问题 I have this dataset: Year Grade count 2010 B2 1 2010 B 478 2010 B1 46 2010 B1 12 2010 B1 2 2010 B2 612 2010 A1 160 2010 A1 8 ... I would like to determine for each year (in the example there is only 2010) the percentage of A1 and B1 over the total in that year, I.e. 478+46+12+2=538 Over the total of B (B1, B, B2) :1202 In order to get the percentage 45%. Similarly for A. I think I should also use like to distinguish between B and A values. How can I do? 回答1: SEL years, Score, ,count(0) ,100.0

Conversion of merge statement to MYSQL using on duplicate key

为君一笑 提交于 2020-05-31 04:06:11
问题 Please suggest how to convert this teradata statement in MYSQL. As we know mysql doesn't support merge statement. Below 2 tables are also being used in select query and we have multiple primary key in each table. MERGE INTO XYZ USING ( SELECT ITRR.WORKFLOW_NAME WORKFLOW_NAME , ITRR.INSTANCE_NAME INSTANCE_NAME , MIN(ITRR.START_TIME) EARLIEST_START_TIME , ITRR.SUBJECT_AREA SUBJECT_AREA , 'INFORMATICA' PLATFORM_NAME FROM ABC IWRR , DEF ITRR WHERE IWRR.WORKFLOW_RUN_ID = ITRR.WORKFLOW_RUN_ID AND

Sum on Multiple Left Joins

荒凉一梦 提交于 2020-04-30 16:33:31
问题 I am trying to sum the total value of a column for a specific ID after multiple left joins. The below code gives me what I am looking for but across multiple rows, I need the value for T3.C_Amt and T4.E_Amt to be totaled. SELECT T1.ID, T2.Unique_ID, T3.C_Date, T3.C_Amount, T4.D_Date, T4.D_Amount FROM TABLE_1 T1 LEFT JOIN DATABASE1.TABLE_2 T2 ON T1.ID = T2.UNIQUE_ID LEFT JOIN DATABASE1.TABLE_3 T3 ON T2.Unique_ID = T3.Unique_ID AND T3.C_Date = '2019-04-11' LEFT JOIN DATABASE1.TABLE_4 T4 ON T2

How do I check and manipulate the data from a flat before loading them to teradata database?

大城市里の小女人 提交于 2020-04-18 06:53:48
问题 As the topic, how do I manipulate the data from the flat file before loading them onto teradata database using BTEQ script.... I'm unsure which part should the manipulation be written onto the bteq script.... USING ------------------------------------------------------ INSERT INTO ------------------------------------------------------ Values In my opinion, data manipulation should be done here ------------------------------------------------------ Table Name : Jerry A ------- | 5 | | 6 | | 7

R-Studio - connection to Teradata is not working

耗尽温柔 提交于 2020-03-25 17:57:15
问题 I have got the issue when trying to connect my R-studio to Teradata. It gives me Error: nanodbc/nanodbc.cpp:983: 08001: [Teradata][WSock32 DLL] (439) WSA E HostUnreach: The Teradata server can't currently be reached over this network however, I was able to login to Teradata from cmd. My code is using DBI connection with standard settings. readRenviron("~/.Renviron") databaseType <- "Teradata" defaultDatabase <- "Test" SERVER <- "tera2" DATABASE <- "teradb" driverList <- odbc::odbcListDrivers(

Python - loop through same query with different variables, merge data frames

假如想象 提交于 2020-03-05 04:38:09
问题 I have a query in SAS where I use a Macro variable to repeat a query to Teradata with a different variable. We have 5 databases, one for each state, where I run the same query, but use the variable to update the state, then mend all data sets. I'm looking for help in how I can do this in python. loop through {state1, state2, state3, state4, state5} and save each query as {stateX}_df then merge all import teradata as td import pandas as pd from teradata import tdodbc udaExec = td.UdaExec

Teradata自增量

孤街浪徒 提交于 2020-02-28 21:58:07
定义两个表如下: create table TEST.i1 ( i INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1 INCREMENT BY 1 NO MAXVALUE NO CYCLE ), STR VARCHAR(20) ) unique primary index i1 (i) ; [ @more @] create table TEST.i2 ( i INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1 INCREMENT BY 1 NO MAXVALUE NO CYCLE ), STR VARCHAR(20) ) unique primary index i2 (i) 往表i2里面插入五条数据(执行5次下列语句): INSERT INTO TEST.i2 (STR) VALUES('1') 将i2的数据导入到i1: INSERT INTO TEST.i1 SELECT * FROM TEST.i2 再往i1里面插入数据: INSERT INTO TEST.i1 (STR) VALUES('2') 会报错: Duplicate unique prime key error in TEST.i1 说明: 自增量每次自增操作后,会做记录(貌似会记录当前最大值)

Python SQL loop variables through multiple queries

可紊 提交于 2020-02-25 04:11:16
问题 I'm having trouble with a Python Teradata (tdodbc) query with looping through the same query with different variables and merging the results. I received good direction in another post and ended up here. My issue now is that the dataframe only ends up with query results of the final variable in the loop, "state5". Unfortunately we have 5 states each in their own databases with the same schema. I can run the same query, but want to loop the variables so I can run for all 5 states and return an

Python SQL loop variables through multiple queries

南笙酒味 提交于 2020-02-25 04:11:05
问题 I'm having trouble with a Python Teradata (tdodbc) query with looping through the same query with different variables and merging the results. I received good direction in another post and ended up here. My issue now is that the dataframe only ends up with query results of the final variable in the loop, "state5". Unfortunately we have 5 states each in their own databases with the same schema. I can run the same query, but want to loop the variables so I can run for all 5 states and return an