Why don't you use JOIN clause.
This is Teradata, not O**e or My***. JOIN is efficient !
SELECT ptn.patient_name
, ptn.Patient_age
, ptn.Patient_weight
, SUM(CASE WHEN drug_name = "Warfarin" THEN 1 ELSE 0 END) AS CountWarfarin
, SUM(CASE WHEN drug_name = "Heprin" THEN 1...
When you need a table containing range of integers, you can use SYS_CALENDAR.CALENDAR.DAY_OF_CALENDAR...
SELECT cal.day_of_calendar AS myvalue
FROM sys_calendar.calendar AS cal
WHERE myvalue BETWEEN 1 AND 1000
You could use calendar view :
select bat.batch_id
, cal.calendar_date as start_date
, case when cal.calendar_date + 30 >= bat.end_date
then bat.end_date
else cal.calendar_date + 30
end as end_date
from batch as bat
inner join...
If you want select duplicate rows on (ACCOUNT_NO, SQN_NO), you could use this request :
select *
from ACCOUNT_TABLE
where (ACCOUNT_NO, SQN_NO) in
( select ACCOUNT_NO
, SQN_NO
from ACCOUNT_TABLE
group by ACCOUNT_NO...
First, password doesn't appear in log file. It's secure on this side.
Second, you can use an external file to store your logon command and call it with .RUN FILE logon_file
It won't be very difficult to create a temporary uncrypted logon_file that will be erased on next bteq.
Something like that...
You can use "derived columns"... :
select 'ABC.DEF.GHI.JKL.MNO' as MYCOLUMN
, substring(MYCOLUMN from 1 for (position('.' in MYCOLUMN) (named POSDOT1)) - 1) as FIELD1
, substring((substring(MYCOLUMN from POSDOT1 + 1) (named SUB1)) from 1 for (position('.' in SUB1) (named POSDOT2)) - 1) as...
Try this :
UPDATE bi_stg_1.tl_compare
FROM ( SELECT COUNT(*) AS cnt
FROM diff_x
) AS x
, ( SELECT COUNT(*) AS cnt
FROM diff_y
) AS y
SET count1 = x.cnt
, count2 = y.cnt
WHERE database_name = 'stg'
AND...
Try this :
SELECT 'Total ' AS Row_One
, Name
, Column2_Sum
, Column3_Sum
, Column4_Sum
, Total_Sum
, RANK(Total_Sum) Total_Sum_Rank
FROM
( SELECT Name
, SUM (Column2) AS Column2_Sum
, SUM (Column3) AS Column3_Sum
, SUM (Column4) AS Column4_Sum
, (Column2_Sum +...
I answered this question on Teradata Discussion Forums a few days ago.
This answer could help other users on this forum...
select T1.EMP_ID
, T1.SPL_EVENT_DATE
, T1.NAME
, T1.ADRESS
, T2.REVISED_MONTHLY_SALARY
from TABLE_1 as T1
inner join
TABLE_2 as T2
on T1.EMP_ID = T2.EMP_ID
where exists (...
you need two bteq scripts inside your Unix shell script :
# Prepare the tmp.sh script and get the run_date value
bteq << first
.logon ??
.export report file ='tmp.sh'
SELECT 'export run_date=' || (run_date (format '??'))
FROM control_table
;
.export reset
.quit 0
first
# Execute the tmp.sh...
Perhaps did you need something else in your record, such as an ORDER_ID for example.
Try this :
select A.NAME
, A.ORDER_ID
, A.ORDER_QTY
from MyTable as A
where exists ( select 1
from MyTable as B
where A.NAME = B.NAME
having A.ORDER_QTY = max(B.ORDER_QTY)
)
;
CHARACTERS() is equivalent to the ANSI SQL-99 function CHARACTER_LENGTH and returns the length of a string expression.
EXTRACT() is a ANSI SQL-99 function. It extracts a single specified field from any DateTime or
Interval value, converting it to an exact numeric value.
FULL JOIN is a...
Test the integrity of your data before inserting :
INSERT INTO doubles (id, columns, batch_no)
SELECT id, columns, $BATCHNO
FROM source
INNER JOIN
target
ON target.id = source.id
;
INSERT INTO target (id, columns)
SELECT id, columns
FROM source
WHERE NOT EXISTS (...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.