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
Tag: teradata
Teradata SQL returning previous two months, based on CURRENT_DATE
TLDR: I want to get a table with the previous two months in Teradata, based on CURRENT_DATE. Currently I can only get the previous month: Expected output is: Long version: I want something, that could be used in a bigger query like this, valid for every day of the year, without hardcoding the dates. The bigger query with the hardcoded
Python – loop through same query with different variables, merge data frames
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
How to select certain number of rows from large query result set in Teradata sql
I am new to Teradata sql and I have a query that selects over one million rows. I want to write teradata sql to select the first 500,000 rows, then the next 500,000 rows and then the last 100,000 + rows in my data set. For the first set I know I can use SELECT * FROM QRY1 ORDER BY
Teradata SQL getting last not null value
I have a table in Teradata that looks like this: Account_Num Install_Due_Dt Install_Num Install_Pay_Dt 12805196 12/08/2019 1 12/08/2019 12805196 10/09/2019 2 …
LEFT JOIN not showing days with zero COUNT
I am trying to retrieve data from the last X days, counting the new rows per day. I need to get also the days that have COUNT = 0. My query right now is: SELECT COUNT(*), CAST(TIMESTAMP_T AS DATE) …
I am trying to create a table in SQL and keep getting an error
I’m using Teradata SQL assistant to create a table. The code I am using is as follows: CREATE TABLE calendar ( CalendarKey INT NOT NULL, FullDate DATE NOT NULL, DayOfWeek VARCHAR(20) …
Split String and Count Teradata SQL
I would like to split column ‘ASPCT_VLU_NM’ and count of occurrences of the timestamps in a given time frame. For example return the ID which have more than 3 occurrence in between 1537160520286 and 1537190520286. In the example below those are the timestamps : Answer If you are using Teradata 14 or later, then you may take advantage of the
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,’…
How to pivot time series table without aggregation
I am pulling sensor data from a Teradata table for analysis. Below is what the table looks like. I want to pivot it such that sensor names become columns. There are more than a hundred sensors and …