Quantcast
Channel: Teradata Forums - Database
Viewing all 14773 articles
Browse latest View live

Transpose columns to row in a single query - response (1) by reddyrajendra2014

$
0
0

MOUSUSI,

sel
 max(case when rn=1 then ref.a end) as X,
         max(case when rn=2 then ref.a end)  as y,
         max(case when rn=3 then ref.a end)  as z    

from
(
sel

a,b
,
row_number() over ( order by a,b )rn
from temp1
)
ref

UNION

sel
         max(case when rn=1 then ref.B end) as X,
         max(case when rn=2 then ref.B end)  as y,
         max(case when rn=3 then ref.B end)  as z    

from
(
sel

a,b
,
row_number() over ( order by a,b )rn
from temp1
)
ref

 


Unicode data - response (4) by reddyrajendra2014

$
0
0

Carlosal, here below am providing example with some data wil give better explanation of my requirement.
ex:

col1
-------
abc
漢字;
abc漢

in col1 i have data like above . But translate_chk providing me below results.
No way i will come to know that this column has unicode data .Correct me if i'm wrong.

sel translate_chk('漢字;' using unicode_to_latin) -- result 0
sel translate_chk('abc' using unicode_to_latin) -- result 0
sel translate_chk('abc' using latin_to_unicode) -- result 0
 

Delete duplicate in a single query - response (2) by Moutusi

$
0
0

Thanks Reddy for your reply. I need the delete SQL. After executing the SQL table(T1) will look like:
Table: T1
A B C
1 2 3
4 5 6
7 8 9
 
 

Unicode data - response (5) by CarlosAL

$
0
0

Check your session character set. It MUST be unicode.
It is working for me as expected:
CREATE TABLE ECI_D.PRUEBAUNI(C_TXT VARCHAR(25) CHARACTER SET UNICODE);
INSERT INTO ECI_D.PRUEBAUNI VALUES ('漢字;');
SELECT TRANSLATE_CHK(C_TXT USING UNICODE_TO_LATIN) FROM ECI_D.PRUEBAUNI;
Translate_Chk(C_TXT using UNICODE_TO_LATIN)
1
 
HTH.
Cheers.
Carlos.

Unicode data - response (6) by reddyrajendra2014

$
0
0

Carlosal, My session char set is ASCII , could you please tell me how to change it to unicode.

Unicode data - response (7) by CarlosAL

$
0
0

What tool are you using?
In bteq: set session charset
In SQLA: depends on the connection (ODBC/.Net), but it's all in the connection parameters window.
In java (Teradata Studio/Eclipse) connection parameters window.
Cheers.
Carlos.

swap values in two columns using update SQL - forum topic by Moutusi

$
0
0

How can I swap both column values using only update statement? No Alter table permitted.
Table: T1 
A B
1 2
3 4
5 6
 
After execution the table will look like:
Table: T1
A B
2 1
4 3
6 5

Forums: 

swap values in two columns using update SQL - response (1) by Glass


collect stats statement failure because of spool space - response (1) by vikash.dwh@gmail.com

$
0
0

Hi Nagendra,
It depend on various parameter
1.What is the spool space allocated to the user X with which you are trying to run and how many
numebr of Amsps u have for Teradata Box.?
2. At the time when u are running the collect stats with user X, is someone else or batch job with the same user X running some SQL/extract on the box.   
3. If you have enough spool space try running the stats in a quiet period.
4. Also what is the size of the table where u r trying to collect the stats...If it is a very BIG table
then it will consume more spool space.
 

Delete duplicate in a single query - response (3) by Glass

$
0
0

Moutusi,
Since ABC is your entire record a single SQL can't distinguish one record from the other with the same three values. You will delete both records.
Inserting into a set table is simple but if you don't have the access to create a new table
You could create a volatile table(set is default) and insert all rows into it, this will get rid of duplicates, then delete all records from TI , then insert  back into your multiset table. Creating a volatile table requires no create table access on a database or perm space.
 
Rglass
 

swap values in two columns using update SQL - response (2) by reddyrajendra2014

$
0
0

Glass , Its awesome . I couldn't expect that solution is this much Easy....

Partition effectiveness - response (2) by levinra

$
0
0

Thanks for your reply Raja, but I don't think that's what I'm looking for.
 
I guess I'm trying to get some assurance that if the optimizer uses a partition for access when it builds the EXPLAIN plan instead of an all-rows scan, I can trust it will be the most efficient access method, regardless of the number of partitions it uses for retrieval.
 
The large number of partitions I saw in the EXPLAIN took me by surprise, and that is why I'm asking about this.
 
Robin

Delete duplicate in a single query - response (4) by Raja_KT

$
0
0

You can also do thus:
create table tmp as
(select * from abc qualify row_number() over (partition by a,b,c order by a,b,c)=1) with data;

Sum of Column_B for each distinct Column_A - forum topic by jayantonhu

$
0
0

How do I take a sum of one column (exposures) if and only if another column (ID) is distinct?  Note that Exposure is a calculated field and will always be the same for a single ID.
I have a table that looks like this:
ID Exposure  Claims
A        1            50
A        1           100
A        1             5
B        .25        1000
C        1            10
C        1            100
C        1            500
C        1            252
Output: 2.25

Forums: 

summing serial numbers in a single column with out using an external function. - forum topic by txwylde

$
0
0

I have an audit table that I am creating a view for so I can create some reporting for. In the original table, ther serials are separated by a comma and are all in one comlumn. Here is an example:
 
serial_number                                                          
-----------------------------------------------------------------------
CO2LM3VGFD57,C8PL83ZZDT9V,D66J23Q0DNQ,DMPGK13SDFJ1                     
YM9402FD72Q,UM830WZZYXX,1B84163E201                                    
F17JLJMSF8GK                                                           
DLXKRBTDF182,DLXKRCD0F182,DLXKRCBZF182,CNU3159MQ4,CNU3159MN0 CNU314BHYY
C02MC0B1FD58                                                           
DLXMZ0U0FH13                                                           
F18L96KNFH1C                                                           
C02KT0MXDRVG                                                           
V5046NVVETV                                                            
C39JQ6GCDTTR 
 
Here is the query I am using to create the view:
 

select 

cast(date_processed as date),

initiator,

SUM((char_length(serial_number) - char_length(apputil_user.oreplace(serial_number, ','))) + 1) as num_serial

from datamining_biz_app4.legal_data_audit

where serial_number <> ''

group by 1,2

order by 1,2;

 

 

Is there a way to sum the serials without using the apputil_user.oreplace function?

 

Thanks!

Bill

 

Forums: 

Different types of Indexes in Teradata - forum topic by srik16

$
0
0

Hello, Looking for the various types of Indexes that are available in Teradata 13, what's the equivalent of Oracle BTree and Bitmap Indexes in Teradata?
Thanks for your help with this.

Forums: 

Sum of Column_B for each distinct Column_A - response (1) by Raja_KT

$
0
0

 
Does it serve the functioanlity if it is:
 
select sum(sm) from
(select id,exposure sm from tabl1 group by 1,2) a
 
it brings 2.25
 

Different types of Indexes in Teradata - response (1) by Raja_KT

$
0
0

Teradata has many indexes such as Primary indexes(unqiue , non unique), Secondary indexes(unqiue , non unique), join indexes, hash indexes,sparse indexes..
rows of tables and indexes are distributed to the AMPs using different methods of row allocation. It is MPP architecture. 
In Oracle in a b-tree, you walk the branches until you get to the node that has the data you want to use. No amps.
Bit map indexes in oracle, is used for low predicates. However, I see that making too many indexes for a system creates havoc. Indexes are created only if there is a need to suit the system performance.

Query Banding functionality in Teradata - forum topic by SriniD

$
0
0

Hi All,
As there was a drwaback “getQueryBandValue” is evaluated once per row, thus increasing CPU utilization. with respect to. Query Banding functionality in earlier versions of Teradata, can someone help me whether this drawback has resolved in the latest versions of TD like TD13, TD14... If yes, please help me to understand how it has been resolved.
 
Thanks in advance,
Sri.

Forums: 

How to limit rows to only those where there are duplicates of a specific column? - response (9) by dnoeth

$
0
0

Hi Chandan,
based on your result set (I didn't fully understand your explanantion) this should work:

CREATE VOLATILE TABLE vt (  ACCT INT,    ID  INT,  code     CHAR(3))
ON COMMIT PRESERVE ROWS;

INS vt(123 ,  2500   ,'AB1');         
INS vt(123 ,  24386  ,'AB2');
INS vt(123 ,  2500   ,'AB3');
INS vt(123 ,  2500   ,'AB4');
INS vt(123 ,  2500   ,'AB5');
INS vt(123 ,  24386  ,'AB6');
INS vt(123 ,  2400   ,'AB7');
INS vt(123 ,  2400   ,'AB8');

SELECT dt.*,
   COALESCE(MAX(x) 
                OVER (PARTITION BY acct
                      ORDER BY code 
                      ROWS UNBOUNDED PRECEDING), code) 
FROM
 (
   SELECT vt.*,
      CASE WHEN id = 24386
           THEN MIN(code) 
                OVER (PARTITION BY acct
                      ORDER BY code 
                      ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING) 
      END AS x
   FROM vt
 ) AS dt
QUALIFY id <> 24386

 

Viewing all 14773 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>