Questions tagged [teradata]
Teradata is a Relational Database Management System (RDBMS), capable of supporting many concurrent users from various client platforms. Teradata is compatible with the ANSI standard and built completely on parallel architecture.
5,166
questions
0
votes
0
answers
22
views
How to subtract multiple day range from current date
Using Teradata -
I know I can subtract days from current date by Current_date -7, but I need to subtract multiple day options from a date field. Say my data field is Completed_Date and I need to pull ...
0
votes
0
answers
25
views
Teradata: On doing PIVOT operation values of columns interchange
I am having a Table (DB.TAB_UNPIVOTED) on TeraData having millions of rows, and 4 columns - ID, Week, Sales & Profits. Here below is a small microcosm of the problem.
For sake of illustration DB....
-1
votes
0
answers
23
views
How to fan out data with SQL?
I got this table:
Is their a way to create values between the DATE values like this?
0
votes
0
answers
30
views
SQL | Use a Inner Join to combine to tables where the last day of month is different
I'm having a bit of trouble here combining data from two tables (via a join) because one table is using the last day of the month whereas the other is using the last working day of the month.
How can ...
0
votes
0
answers
18
views
Teradata SQL Assistant import data with commas
I was following instructions with teradata sql assistant in order to import a CSV file into teradata with the following command:
Everything seems to work fine except that the dataset contains strings ...
0
votes
0
answers
18
views
No remaining space in Teradata Database
I created a database of storage 18 gb using:
CREATE DATABASE demo FROM DBC
AS
PERM = 18000000000, -- 18GB
SPOOL = 15000000000; -- 15GB
NO FALLBACK
NO BEFORE JOURNAL
NO AFTER JOURNAL;
I need to load ...
0
votes
0
answers
22
views
Selected Non_Aggregate Values must be part of the associated group
I get the error message 'Selected Non_Aggregate Values must be part of the associated group' when running the script below. I only have 2 non-aggregated columns that are specified in the group by ...
1
vote
1
answer
22
views
Teradata SQL Get Most Recent Single Customer By Item
I am struggling in getting the most recent single customer by item. I have a table with sales information like the following
ITEM INVOICE_DT CUST_NM SALES_AMT
ITEM1 1/5/2022 CUST1 100
ITEM1 ...
0
votes
1
answer
26
views
Using a history table, how can I identify each period of time in which any task is active, and reduce the data set to non-overlapping date periods
I have a history table in Teradata that contains information about tasks that occurred on an account. In typical history table fashion, the data present has a Load (Valid From) and Replace (Valid To) ...
0
votes
0
answers
25
views
Data Transfer from Hive table to Teradata table
I have a table (employee) in a Hive database (company) with a record count greater than 41 million. The table is partitioned on current_date column.
select count(*) from company.employee
The result ...
0
votes
0
answers
23
views
Breaking down existing SQL Query into manageable chunks [closed]
I am very new to SQL and I have a minefield of a SQL query to unfold, and break down into manageable chunks to basically understand what this is doing so that I'm able to re-write the code out from ...
0
votes
1
answer
27
views
How to import Teradata table into HIVE using HUE?
I need help importing a Teradata table (with LDAP credentials) into HIVE using HUE interface. I'm new to HIVE and has very little knowledge. Also, the import needs to be a fresh load and not append.
...
0
votes
1
answer
37
views
Liquibase : Expected something between the "TABLE" keyword and the "IF" keyword
I am trying to run the below sql by liquibase and I am getting an error expected something between "TABLE" and the keyword "IF" keyword .This is for teradata database
CREATE ...
0
votes
1
answer
27
views
Teradata - YEARFRAC equivalence
I am having a hard time trying to find something that would be equivalent to YEARFRAC (Excel) for Teradata. I messed around with the below, but want I want it to display the fraction of the year. So ...
0
votes
1
answer
36
views
Selecting values in a partition where a condition is met (Teradata SQL)
I have table that is in the following format:
Number
Departing
Arriving
Departure Time
Removal Indicator
1
Miami
Dallas
1 PM
N
1
Chicago
Dallas
3 PM
Y
1
Dallas
Miami
5 PM
N
In this partition, I ...
2
votes
1
answer
77
views
Teradata: IN clause in Pivot can't take data from Table
I wish to extract a few Calender Weeks from an yearly data. Once that's done, I want to pivot it, so that there is one row for each ID.
We have a table DB.MY_CWs having just one column CW containing ...
0
votes
0
answers
19
views
split int col in Teradata
I was trying to split int column in Teradata but its showing error
*** Failure 9134 Unsupported type detected.
SELECT col1,strtok(col2,0 ,1) FROM table;
-1
votes
0
answers
9
views
How to enable TLS on Teradata Express
I have installed Teradata Vantage Express on an Azure VM according to these instructions: https://quickstarts.teradata.com/run-vantage-express-on-microsoft-azure.html - this installs the database on a ...
0
votes
0
answers
18
views
Teradata Stored Procedure Access issue
Am trying to execute a procedure on teradata and it seems to be I don't have privileges to execute the procedure, even the SP owner isn't able to grant access to me.
Is there other way around to get ...
0
votes
4
answers
47
views
How can I select the first and second to last record for a given group in SQL?
In Teradata I need to select the first record for a group as well as the second to last record for the same group for multiple groups with other set conditions. How can I acheive this?
ex table:
...
0
votes
1
answer
26
views
Teradata : Extract Date from string
There is a notation field with different number of characters. Eg
Exceed Limit Fee 26-January-2020
or
Account Exceed Limit Fee 05-June-2001
I want to extract date part of it and convert that to date ...
0
votes
2
answers
26
views
Is there a way to flatten values in a table using rank function?
I have a table in SQL which looks like this -
ITEM
ACTIVITY_ID
ACTIVITY_TYPE
ACTIVITY_DATE
Item 1
Activity A
Call
Jan - 1 - 2022
Item 1
Activity B
Mail
Jan - 10 - 2022
Item 1
Activity C
Print
Jan -...
0
votes
0
answers
30
views
replace qualify to use in Spark SQL
I want to convert this Teradata sql to Spark compatible SQL, hot to do it?
SELECT * FROM table_name qualify rank(col_name)=1;
0
votes
0
answers
16
views
Locking Row for Access in Presto SQL, udw in Teradata
Hi I'm trying to access teradata tables using Presto SQL and I get a Locking error. I can't use Locking Row for access in Presto SQL because it doesn't support it. So why is there a locking error in ...
0
votes
0
answers
41
views
sqoop import error HCat exited with status
I am running the following sqoop import from Teradata:
sqoop import --driver com.teradata.jdbc.TeraDriver \
--connect jdbc:teradata://telearg7/DATABASE=AR_PROD_HUB_DIM_VW,CHARSET=UTF8,...
0
votes
1
answer
27
views
A count of all duplicate rows
I am trying to find out how many of my rows are duplicates with any other row in my table.
Any help would be really appreciated
Select *
From DB
This gives me a count of all rows but I can’t figure ...
1
vote
1
answer
17
views
number pattern matching in Teradata
I was trying to get the rows matched with a pattern by using like in Teradata
select * from table_name where col_name like '10%';
here I wanted to get all the rows with column values like 1000, 101, ...
-1
votes
1
answer
26
views
Adding columns without using left joins in SQL
In (Teradata) SQL I want to change the structure of a table. Currently I am using left joins but perhaps there is a more efficient way to do it.
The table contains processes related to packages with ...
0
votes
0
answers
22
views
Teradata Result set view
When trying to run this query/command:
CREATE MULTISET VOLATILE TABLE SRB AS
(
SELECT
-- As the grain of this table is Account x Cuustomer, all Account amounts are divided by number of ...
0
votes
1
answer
30
views
Migrating Microstrategy reports from on prem with Teradata as backend to Microstrategy Cloud with snowflake as backend
We have the Microstrategy reports pointing to Teradata as backend. The plan is to migrate the Microstrategy from On Prem to Microstrategy Cloud with Snowflake as backend.
I wanted to know the steps ...
0
votes
1
answer
36
views
How to find the line number of error in Teradata SQL Assistant
I'm new to Teradata SQL Assistant and have a simple issue that couldn't find the solution in Terada documentations.
How I can find the exact location of this error?
0
votes
1
answer
32
views
Teradata SQL - how to get data between current month and current month+8 (current month+8 will fall into 2023)
I have this code but returns 0 row:
SELECT
EXTRACT(MONTH FROM POST_DATE)
FROM
MY_TABLE
WHERE
EXTRACT(MONTH FROM POST_DATE) BETWEEN EXTRACT(MONTH FROM CURRENT_DATE) AND EXTRACT(MONTH FROM ADD_MONTHS(...
1
vote
1
answer
75
views
Recursive SQL to eliminate duplicates?
I have a SQL, where I need to make assignments between ids, but only if there is exactling one "matching partner".
orig table:
id_orig
id_new
1
2
3
5
4
10
98
200
100
200
100
300
...
0
votes
1
answer
30
views
Teradata: How to remove character \x00 & \x02 from data
I am loading data from a teradata database like:
df = spark.read.format("jdbc").option("url", "jdbc:teradata://url_of_teradata_db/MAYBENULL=ON,TYPE=FASTEXPORT,charset=ASCII&...
0
votes
0
answers
22
views
Is it possible to use row access locking when using SCRIPT command in Teradata
I'm trying to process the data in the table using an external script (Linux binary) with the SCRIPT_COMMAND function. However I cannot make it work so that row access lock is applied.
By default read ...
0
votes
1
answer
45
views
Join two tables and excluding
SELECT *
From BANK.TXN_DLY
WHERE TXN_DT BETWEEN '2022-01-01' AND '2022-03-31'
AND TXN_CD IN ('502');
SELECT *
From BANK.TXN_DLY
WHERE TXN_DT BETWEEN '2022-01-01' AND '2022-03-...
0
votes
2
answers
48
views
Full outer join acts like inner join with multiple conditions on the two tables
I am trying to have a full outer join between two tables Table1 and Table2 on ID with a query like the following in Teradata. The problem is it acts like inner join.
SELECT *
FROM Table1 AS a
...
0
votes
3
answers
59
views
How do I combine YEAR and MONTH into a DATE?
I'm looking for an easier way to do this. My current code is written as below:
CASE WHEN LENGTH(CAST (MTH AS VARCHAR(4))) = 1
THEN CAST(CAST (YR AS VARCHAR(4))||'-0'||CAST (MTH AS VARCHAR(4))||'...
0
votes
2
answers
36
views
Teradata: How to display LOB inline(inside the cells)
I have a Teradata table which contains LOB objects in different columns.
When I do a query, it pops up window to ask where to save the LOB objects as txt files onto my disk.
LOB Information (due to my ...
0
votes
2
answers
60
views
Teradata merge multiple records into single record
I want to merge multiple record into single record
Ex:
Input
pdt
status
start_dt
end_dt
a
Inactive
2022/02/02
2022/02/04
a
Inctive
2022/02/05
2022/02/10
a
Active
2022/02/10
2022/02/12
b
Active
...
0
votes
0
answers
44
views
How to use a select within an inner join
I did this UPDATE to put 1 or 0 in the column GESTOR_ATIVO:
UPDATE DIM_GESTORES
FROM
(SELECT
G.COD_EMPRESA
, G.MATRICULA
, GES.SITUACAO_GESTOR
, CASE
WHEN GES.MATRICULA = G....
0
votes
0
answers
37
views
Performance tuning using NOT EXISTS in Teradata
IE_VT is a volatile table that is created with UNIQUE PRIMARY INDEX ( STORE_NUMBER, UPC, POS_DEPT, POS_DEPT_NUMBER )
Now our code tries to insert into the VT by selecting few columns from various ...
1
vote
3
answers
48
views
how to delete a value from a column in SQL
How can I delete only the field of a column without deleting the entire row? I have a table that owns the fields:
ID, Name, Mail, Phone, Company and Would like to delete only the email of a person ...
0
votes
1
answer
28
views
Any idea what function or logic can be used to achieve this output?
Question:
Table A has one column with 4 values
col 1
-----
1
2
5
8
Output
col 1 col 2
----- -----
1 2
2 10
5 40
8 8
Output should be the existing column with a ...
0
votes
0
answers
41
views
facing issues in connecting to Teradata via python using teradatasql Module
Code:
import teradatasql
ExecutionContext = teradatasql.connect (host="xxxx", user="xxxx", password="xxx")
def select(exec_context: ExecutionContext):
try:
...
2
votes
1
answer
34
views
Teradata SQL repeat insert statement
pretty new to teradata and trying to figure out how to repeat a simple insert statement.
I have the following statement
Insert into Test (Id) values ((sel max (Id)+1 from test))
And I would to repeat ...
0
votes
1
answer
59
views
Teradata CONCAT a String and a modified Date format
I am trying to CONCAT a String and a Modified date format. I have two requirements
First one, I need the output to be in the output window be like
Cost Month: Month YYYY format( where month should be ...
0
votes
0
answers
25
views
How can I insert the script executed in a stored procedure into a tab of an excel file/
I have a stored procedure and I am calling it in excel using VBA. Now, I want to insert the script executed (with the variables used, not the parameters) into a tab of the same excel file called "...
2
votes
2
answers
44
views
SQL - Flag rows till 0 value of each group
I am calculating a running balance and want to flag all rows till 0 value to have 'MATCHED' flag else 'NOT-MATCHED' flag with respect to account ID.
Here is what I have tried but didn't got proper ...
0
votes
2
answers
56
views
Show members that have a consistent doctors visit, after the first visit till the day of delivery
SELECT DISTINCT
DEL.BABY_ID,
DEL.MOTHER_ID,
MIN(DEL.CHECK_VISIT_DATE) OVER (PARTITION BY DEL.MOTHER_ID) AS Del_FIRST_DATE,
(DEL.CHECK_VISIT_DATE) VISIT_DATE,
DEL.BABY_BIRTH_DATE,
...