I have table in Teradata SQL like below: The first value is always: “O|” then there is 4 numbers and so on… I need to create new column only with these 4 numbers code, so as a result I need something like below: How can I do that in Teradata SQL ? Answer Use STRTOK
Tag: teradata-sql-assistant
Select and skip rows by date range with checking difference between them
I’m new in Teradata and i have a small sql problem, similar to this one below : source table A: output wanted: Explanation: 1 –> if c is different (between current row and the next one) so dt_f of the current row = dt of the next row – 1 day , the two rows are selected 2–> if months_between(dt,dt)
Is there a way to group rankings in SQL Teradata?
I am trying to get the ranking or grouping to count like in the custom_ranking column: I want it to count the rank like in the row custom_ranking, but everything I keep trying is counting it in the current_ranking row. I am currently using this: Answer Based on your sample data, this would be:
Assigning column value based on condition on another column in sql (teradata)
I have a table which has the following columns: Date, AcctId, CustID, BackupID, Logins, Amount. For a given Date, an AcctID can more than one CustIDs, but I want to assign a singular CustID to an AcctID based on the value of Logins. i.e.: If Cust1 has more Logins than Cust2 for the given Date and AcctID then CustID should
Concatenate in sql teradata
I have the following code Sel account, Div, Modl, Sub_modl From table_1 Where Div gives me 01, Modl = 1 is CS, and Sub_modl=1. I should combine these fields to have: 01_CS_0101 Where the first 01 …
Delete rows where string value appears inside another row value that is larger
I am trying to make a table smaller by removing values that appear inside other larger values. e.g. Column Row1 potato234 Row2 to2 Row3 ot Row4 potatos The outcome I want is for row 2 and 3 to …
SQL Logic Check
I’m new to SQL/Teradata. The numbers I got from the 2nd query are not what I expected, which leads me to believe I am doing something wrong. I have two conditions I want to count by: Condition 1: Condition 2 (All other Permutations): Query for Condition 1: I think this one is wrong . . . Query for Condition 2
Teradata SQL help. Need help getting the start date and end date (yellow) of the most recent employment status. Thank you
Teradata SQL help. Need help getting the start date and end date (yellow) of the most recent employment status. Thank you. Click on the question for image. Answer There are several ways to get your expected result, based on your data you might apply Teradata’s NORMALIZE option, a SQL extension to combine overlapping periods: Caution : This returns a new
SQL Date Range Specification, Explicit vs BETWEEN()
My understanding of SQL is that is the same as But I’m getting completely different ResultSets when the only difference in the queries is the date range specification. The correct dates are being returned but the data is different. This is happening in both Teradata and HANA. Am I missing something? EDIT: AS POINTED OUT THIS IS THE RESULT OF
Converting Varchar(200) to YYYY-MM-DD format in Teradata SQL
I have a Varchar like so: 23FEB2025 I am trying to convert it into a format like: 1994-02-23 or YYYY-MM-DD I have tried select cast (’23FEB2025′ as date format ‘yyyy-mm-dd’); and sel convert(date,’…