Teradata Table Naming - response (17) by rnekkanti
Help with SQL for reporting month totals - response (15) by satyam12
HI,
Need help to with SQL to solve below.
My table contains tow columns Member number and elig date (which is always beginning of the month)
Member # Elig_dt Expected Result (no. of months continuously eligible)
============= =============
M1 2015/01/01 1
M1 2015/02/01 2
M1 2015/03/01 3
M1 2015/12/01 1
M2 2015/01/01 1
M2 2015/02/01 2
M2 2015/12/01 1
I need to count no. of months a member is eligibile without interruption. if interruption the counter should be reset to 1
Any help from any one is greatly appreciated.
Thx
How do i write qualify rank() over (partition.....question - response (5) by raj786
how to get dense rank in teradata?
is there any dense_rank() function available in teradata
Help with SQL for reporting month totals - response (16) by dnoeth
What's your Teradata release?
Since 14.10 there's LAST_VALUE:
select Member, Elig_dt, -- find the previous gap's row number rn - last_value(case when flag = 1 then rn -1 end ignore nulls) over (partition by Member order by Elig_dt rows unbounded preceding) from ( select Member, Elig_dt, row_number() -- row number without reset over (partition by Member order by Elig_dt) as rn, case when min(Elig_dt) -- check for gap over (partition by Member order by Elig_dt rows between 1 preceding and 1 preceding) >= add_months(Elig_dt, -1) then 0 -- no gap else 1 -- gap end as flag from tab ) as dt
How do i write qualify rank() over (partition.....question - response (6) by dnoeth
It's available since TD14.10, before you need to rewrite it:
Missing Functions: DENSE_RANK
Teradata Table Naming - response (18) by david.craig
There is no separate limit for load utility table names. How are you determining that there is a limitation?
Teradata Table Naming - response (19) by Adeel Chaudhry
Multi/Fast-Load are obsolete now. Can you try with TPT which is a replacement for them?
Data type does not match a Defined Type name error - response (3) by Adeel Chaudhry
When you copy SQL from other tool (mostly) it can have some special characters. You might want to try pasting the SQL in Notepad++ or other tool which can show hidden characters as well.
need to test a query using three diff dates - response (2) by Adeel Chaudhry
SELECT CURRENT_DATE, CURRENT_DATE - 1, CURRENT_DATE - 2
MERGE statement problem with IDENTITY field on TARGET Table - response (1) by Adeel Chaudhry
The following should help resolving this issue:
https://forums.teradata.com/forum/database/using-merge-into-a-table-with-an-identity-column-result-failure-5758
LOCKING TABLE table_name FOR ACCESS can be blocked by other locks - response (4) by Adeel Chaudhry
LOCKING ROW FOR ACCESS will give you the dirty read. Check the Teradata documentation, there is a matrix of which locks can supercede and stuff. It would help.
BTEQ hangs for large BTEQ file - response (3) by Adeel Chaudhry
How are you processing the BTEQ file? Doesn't seem to be a BTEQ issue rather perhaps the shell issue perhaps.
Getting Error Message inside a Stored Proc Exception Handler - response (1) by Adeel Chaudhry
Looks good. Are you sure you want to continue after getting an exception?
Alternative for Multiple Left outer join - response (1) by Adeel Chaudhry
In one line, there is no alternative to LEFT OUTER JOIN.
Regarding fixing performance .... How are the tables designed? What the joining columns? What is the PI? .... search forum and you will get many scenarios of performance issues.
There is no magic to performant queries. :)
unknown data in table - response (1) by Adeel Chaudhry
Have you contacted Teradata CS? If no, you should. If yes, they must have an answer to why it happened.
Varchar column reduces to 255 chars in result set - response (1) by Adeel Chaudhry
Does your query include UNION/UNION ALL? Can you share your query?
Hierarchial Data Sorting - response (1) by Adeel Chaudhry
Whats the structure of the table? Parent & child are in separate columns or in one? Have you tried ORDER BY Parent, Child?
DateAdd and DateDiff function in Teradata?? - forum topic by PeterSchwennesen
On SQL Server you can do something like DateAdd(ms, DateDiff(ms, date1, date2), date1)/2
To get the mid date between two date 2016-02-03 12:00:00 and 2016-02-03 14:00:00, you should get the result 2016-02-03 13:00:00.
How do you do that in Teradata when you have two timestamp(6) values?
Peter Schwennesen
How to update the current row value based on the previous row value of the same column - forum topic by S_GALILEO
Dear all,
I have the following data:
DATE CODE RANK ? ABS 0 12/04/2014 RET 0 20/04/2014 STT 0 01/05/2014 RETk 0 13/05/2014 RETj 0
RANK is the column I want to calculate in my SQL given the columns DATE and CODE. It's initialized here to 0.
The logic i want to implement is as follows:
If date = '?' (that is the first line)
If CODE = 'ABS' THEN 0 ELSE 1
Else
If RANK - 1 (previous RANK value) = 1 AND CODE = RET THEN RANK = 2
Else 0
I cannot figure out how to update the current column value given the previous one... I tried many logic implementation with OLAP functions without success.
Can anyone give me a hint?
Regards.
DateAdd and DateDiff function in Teradata?? - response (1) by dnoeth
Hi Peter,
as long as the difference between the timestamps is less than 10000 days:
SELECT TIMESTAMP '2016-02-03 12:00:00' AS ts1, TIMESTAMP '2016-02-03 14:00:00' AS ts2, ts1 + ((ts2-ts1 DAY(4) TO SECOND)/2)
Hi Guys,
I see that my database(ver:15.00.04.03) allows table names > 30 (I think 128 char limit is in place in our envronment) . But i still see the ET,LT,WT tables created during MLOAD still confine to 30 character limit . Is there a separate limit for these utility tables created at runtime ?.
I am not able to find any specific limits in the documentation. Can somebody let me know if there is a limit on these utility tables ?