teradata-sql-assistant

Conversion of Teradata sql to MYSQL sql

假装没事ソ 提交于 2020-06-29 05:17:36
问题 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

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

Calculate variable of max amount in a group

这一生的挚爱 提交于 2020-05-17 08:49:32
问题 I have difficulties in doing the following exercise. I would need to find how frequent is that an id is not the max_id in the group with the most amount . This should be done considering groups that contain at least two different people. Data comes from two different tables: max_id comes from table1 (I will call it a )as well as user and amount ; id comes from table2 ( b ) as well as group. From the text above, the conditions should be (1) a.id<>b.max_id /* is not */ (2) people in group >=2

rows between 1 preceding and preceding 1

空扰寡人 提交于 2020-01-06 06:06:09
问题 I am new to SQL and I want to know what exactly the function ( rows between 1 preceding and 1 preceding )do in teradata ,I want a simple clarification please ,I am trying to use this function as a testcase to get the time gaps in history table between start and end date,can anyone help please or provide any useful links. SELECT DISTINCT CUST_ID FROM ( SELECT CUST_ID, STRT_dt - MIN(END_dt) OVER (PARTITION BY CUST_ID ORDER BY END_dt ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) AS diff FROM table

TeradataSQL: Time to String, Add to Date and Compare to Another Time and Data

强颜欢笑 提交于 2019-12-24 20:25:32
问题 I'm trying to figure out the cleanest way to do a comparison in Teradata SQL Assistant. I have the scheduled start date (TimeStamp), the Schedule start time (varchar), actual start and end times (TimeStamp). I need to consolidate the scheduled start date and time and be able to compare it to the actual start and end date and time without modifying the original data (because it's not mine). I realize that the Scheduled Start Time [SST] is in a 24 hour time format with a AM/PM suffix, but like

Implement aggregation in Teradata

爱⌒轻易说出口 提交于 2019-12-23 04:41:33
问题 I want to aggregate 2 fields proct_dt, dw_job_id in ascendinng order My scenario would be clear by using below queries and result. First query :- sel * from scratch.COGIPF_RUNREPORT_test1 order by proct_dt,dw_job_id where dw_job_id =10309 Output :- dw_job_id proct_dt start_ts end_ts time_diff 1 10,309 2018-03-06 00:00:00 2018-03-06 07:04:18 2018-03-06 07:04:22.457000 0 2 10,309 2018-03-06 00:00:00 2018-03-06 06:58:50 2018-03-06 06:58:51.029000 0 3 10,309 2018-03-07 00:00:00 2018-03-07 06:35

Implement aggregation in Teradata

拥有回忆 提交于 2019-12-23 04:41:08
问题 I want to aggregate 2 fields proct_dt, dw_job_id in ascendinng order My scenario would be clear by using below queries and result. First query :- sel * from scratch.COGIPF_RUNREPORT_test1 order by proct_dt,dw_job_id where dw_job_id =10309 Output :- dw_job_id proct_dt start_ts end_ts time_diff 1 10,309 2018-03-06 00:00:00 2018-03-06 07:04:18 2018-03-06 07:04:22.457000 0 2 10,309 2018-03-06 00:00:00 2018-03-06 06:58:50 2018-03-06 06:58:51.029000 0 3 10,309 2018-03-07 00:00:00 2018-03-07 06:35

Alternative to Case when with subqquery to avoid error (Illegal expression in When clause within case statement)

醉酒当歌 提交于 2019-12-13 03:41:48
问题 My table structure looks similiar to this Customer_id Country item_type Order_Size Dates Codes A401 US Fruit Small 3/14/2016 11 A401 US Fruit Big 5/22/2016 12 A401 US Vegetable Small 7/12/2016 11 B509 US Vegetable Small 3/25/2015 92 B509 US Vegetable Big 3/15/2014 11 B509 US Vegetable Small 3/1/2014 34 A402 CA Fruit Small 3/14/2016 56 A402 CA Fruit Big 5/22/2016 76 A402 CA Fruit Small 7/12/2016 85 A403 CA Vegetable Small 7/12/2016 11 A403 CA Vegetable Small 3/25/2015 16 A403 CA Vegetable Big