How can we use the Resusage tables to derive Resource utilization percentage(system wide)?
Using Resusage tables - forum topic by Kishore_1
3754: Precision Error Float type constant or during implicit conversions - response (2) by CCSlice
Correcting the corrupted record - forum topic by KVB
Hi,
CT BBC(EMPNO INTEGER,ENAME VARCHAR(10),DW_EFF_DT DATE, DW_EXPR_DT DATE,CURR_IN INTEGER,RCV_IN INTEGER,COD VARCHAR(10),ADD_DT DATE)
INS INTO BBC VALUES(1,'A','2014-01-01','2014-01-04',0,1,'T','2014-01-01');
INS INTO BBC VALUES(1,'A','2014-01-05','2014-01-09',0,1,'I','2014-01-01');
INS INTO BBC VALUES(1,'A','2014-01-10','2014-01-19',0,1,'T',NULL);
INS INTO BBC VALUES(1,'A','2014-01-20','9999-12-31',1,1,'T','2014-01-01');
Here due to source error,NULL was inserted unnecessarily,now i want to correct
My output should be
1,'A','2014-01-01','2014-01-04',0,1,'T','2014-01-01'
1,'A','2014-01-05','2014-01-09',0,1,'I','2014-01-01'
1,'A','2014-01-10','9999-12-31,0,1,'T','2014-01-01'
When I am doing SEL T.*,ROW_NUMBER() OVER(PARTITION BY EMPNO,ENAME,COD ORDER BY DW_EFF_DT ) FROM BBC T
The first row is also taking into picture bcoz of partition by in rownum.Here where i got strucked.
Regards
KVB
BTEQ exporting multiple files based on column value in a table - forum topic by uco
Hi
Can anyone please give me some thoughts on this
I have a scenario where I need to create multiple extract files based on a column values using bteq script and in unx environment.
example
table abc
C_Name ID
xxxxx 1
yyyy 1
aaaaa 2
bbbbb 2
ccccc 1
Now i need to create files based up on ID and the outfile name should Name_ID.txt (Eg: Name_1.txt).
And Name_1.txt should have 1's Data only...
There are many more columns in the extract but for example i am using 2 columns
thanks
Krish
Correcting the corrupted record - response (1) by KVB
In the simple sens,I need to find the minimum effective date of consecutive duplicates (empno,ename,cod) only.
So after first row,it's again the third row.So I need to get first as well as third row.
Join Issues - Need help in most efficient way to solve the problem - response (13) by krishaneesh
create table shopping (ShopNbr integer, Item integer) primary index (shopnbr); insert into shopping values (1, 100); insert into shopping values (1 ,101); insert into shopping values (1 , 102); insert into shopping values (2, 101); insert into shopping values (2 ,104); insert into shopping values (3 , 100); insert into shopping values (3, 102); insert into shopping values (3 ,103); insert into shopping values (3 , 104); insert into shopping values (3, 105); insert into shopping values (4 ,103); insert into shopping values (4 , 104); insert into shopping values (4, 105); --create a permanent table with the distinct combination of shops create table shop_list as( sel a1.shopnbr shop1,a2.shopnbr shop2 from shopping a1,shopping a2 where a1.shopnbr<>a2.shopnbr group by 1,2) with data primary index(shop1,shop2); --The below will give 2 of the rows for the same combination sel shop1,shop2,count(*) from (sel b.shop1,b.shop2,item from shopping a join shop_list b on a.shopnbr=b.shop1 union sel b.shop1,b.shop2,item from shopping a join shop_list b on a.shopnbr=b.shop2) c group by 1,2 order by 3 desc
Join Issues - Need help in most efficient way to solve the problem - response (14) by krishaneesh
shop1 shop2 Count(*) 3 2 6 2 3 6 1 4 6 3 1 6 4 1 6 1 3 6 4 3 5 3 4 5 1 2 4 2 1 4 4 2 4 2 4 4
The above mentioned is a bit cumbersome process but can be extrapolated for 5 shop combinations. This can be done with a volatile table. but if the report is required then instead of building volatile table multiple times, a permanent list with all the combinations of shops would be an idea. Here i considered only a combination of 2 shops in whcih we will get 4P2 conmbinations. the first 2 rows of the output points to the same combination.
HTH
Join Issues - Need help in most efficient way to solve the problem - response (15) by krishaneesh
create table shop_list2 as( sel a1.shopnbr shop1,a2.shopnbr shop2,a3.shopnbr shop3 from shopping a1,shopping a2,shopping a3 where a1.shopnbr<>a2.shopnbr and a2.shopnbr<>a3.shopnbr and a1.shopnbr<>a3.shopnbr group by 1,2,3) with data primary index(shop1,shop2,shop3); sel shop1,shop2,shop3,count(*) from (sel b.shop1,b.shop2,b.shop3, item from shopping a join shop_list2 b on a.shopnbr=b.shop1 union sel b.shop1,b.shop2,b.shop3, item from shopping a join shop_list2 b on a.shopnbr=b.shop2 union sel b.shop1,b.shop2,b.shop3, item from shopping a join shop_list2 b on a.shopnbr=b.shop3) c group by 1,2,3
Join Issues - Need help in most efficient way to solve the problem - response (16) by krishaneesh
This would be for combination of 3 shops. Notice that there would be 3 join conditions whn joining the 3 tables instead of 2 joins for 3 tables. With the limited data that i have, the result of this is only 6 for all the combinations but i am sure this will work for 1000 with 5 combination. This would definitely involve heavy cpu particulary during the first create table step. Also please be aware that there would be repeating combinations like with 3 shops 124,142,421,412,214,241 correspond to the same combination but all of them will have the same result. Similarly when dealing with combination of 5, it will have the 5! vlaues having the same combination(i.e., if we have only a single combination maximum, then that will have 120 combinations corresponding to the max value but any one of them can be taken).
compression calculations - forum topic by n_shashi
Hi,
I've a requirement of finding the columns which are best suited candidates for compression. I've around 80 tables in my database. Can somebody suggest if we have any SQL's which give us calculations related to compression so that columns for compressin can be decided.
Thanks in advance
finding links between two col values.. - response (8) by BPP
Thanks Dieter. Looks like it is grouping them correctly, I will have to test it out with our data. Thanks for giving the directions If rows or its size would be a problem, I can try it out with a proc. thanks once again.. you are simply briliant! :-)).
Merge statement showing 0 records merged - response (6) by TD_lover
Soumik,
MERGE statements running from SQL Assistant does not work properly because it is a BTT transaction mode.
Try the same query in BTEQ with ANSI transaction mode and let me know.
Cheers.
Date as Integer - response (22) by NewAmigo
I dont have access to the SP's and i am on TD12, so decided to write a series of Insert and update statements to tackle the type2 objects.
Source Table A
Target Table B, i want to update this table based on table A, i want to keep the history so added Effective_Date_From/To to the target table if the values changes in a column.
Written a few insert and update statements, but the target table is not updated...am i missing something here??
Insert INTO B select ST.Client_ID, ST.Business, ST.Segment, Current_Date, NULL from A ST LEFT OUTER JOIN B ED ON ST.Client_ID=ED.ClientID_PK AND ED.Effective_Date_To IS NULL where ED.ClientID_PK IS NULL; UPDATE B FROM A ST SET Effective_Date_To= Current_Date where ST.Client_ID = B.ClientID_PK and B.Effective_Date_To IS NULL; Insert INTO B select ST.Client_ID, ST.Business, ST.Segment, Current_Date, NULL from A ST LEFT OUTER JOIN B ED ON ST.Client_ID=ED.ClientID_PK AND ED.Effective_Date_To IS NULL where ED.ClientID_PK IS NULL;
How to restore perticular TABLE from backup location in TERADATA. - forum topic by DeepakDhabade
Hi,
I am new to TERADATA technology, recently we took backup of our teradata database (which is of 3.6 TB). Now we are trying to restore sample table by using that backup. Later if succeed in one perticular table then we will moving ahead to restore whole database.
Problem which we are facing is, as we are new to this, Can anyone guide us to do the needful, Or anyone share us the scripts which will help us to restore the sample tables ???
Urgent help required.
Regards,
Deepak Dhabade
How to reduce duplicate Access Rights entries from Teradata database - forum topic by DeepakDhabade
HI,
As we are new to TERADATA technology, Can anyone guide us to reduce the duplicate Access Rights entries from Teradata database ??
Presently in our teradata system, there are many duplicate entries made for single purpose. We need to make these access rights unique.
Can anyone share the related scripts OR useful information then I would appreciate them.
Urgent help required.
Regards,
Deepak Dhabade
Using Resusage tables - response (1) by david.craig
See the reference documentation which covers the Resource Usage Macros and Tables.
Teradata SQL Assistant displays Arabic in reverse order - response (1) by david.craig
It should work, according to the SA reference documentation:
Displaying Unicode® Data
To display languages such as Arabic or Hebrew, which are normally displayed from right to left, use the Regional Settings option of Windows Control Panel to install the required language support files.
The char2hexint function will return the characters in the order they occur in the string:
sel char2hexint('تاءاشنا');
*** Query completed. One row found. One column returned.
Char2HexInt('تاءاشنا')
----------------------------
062A062706210627063406460627
For more information on writing direction see:
http://www.unicode.org/faq/bidi.html#3
How to restore perticular TABLE from backup location in TERADATA. - response (1) by krishaneesh
Are you using Tara gui. if so you can generate it using Task>>Restore menu which will ask for the table that you want to restore and the credentials. One you select that you can ask to build script which builds the scrip . it also asks for the number of sessions. Once you have the script you can make modifications as required and ask Tara to launch it. Fro more information on the commands used please verify the user manual.
Date as Integer - response (23) by krishaneesh
what are the columns that you think are changing in the table B versus A, you need to mention them as <> conditions in your update like
Update B
from A ST
Set Efftctive_Date_tb=current_date
where st.client_id=B.clienid_pk and
(ST.business <>B.business or ST.segment<>B.segment)
and B.effective_date_to is nUll;
This implies that only if there is a change in the values the old value will be updated else not.
Extracting Mulitple fields from a text file for use in an UPDATE statement - forum topic by spidermonk
This is a little tough to explain but here goes. By using Recursive coding I was able to extract multiple dates(99/99/9999) from a text file into multiple records.
EXAMPLE table tab_a Patient a
NOTE_TEXT field: On 12/31/2010 we had a New Years Eve party but I didn't feel good until 01/04/2011. Therefore, next year I will start practicing on 12/21/2011 to get in shape.
Output: Table tab_b
Pat a 12/31/2010
Pat a 01/04/2011
Pat a 12/21/2011
In table tab_a there is only 1 record for Pat a but as you can see there's multiple records for tab_b. My goal is to update tab_a 3 different times using a UDF.REPLACE_CHAR function. The output would then look like this:
On DAY 1 we had a New Years Eve party but I didn't feel good until DAY 5. Therefore, next year I will start practicing on DAY 356 to get in shape.
I don't have an issue if it's a straight one-to-one relationship. Is there any easy way to perform an UPDATE statement that doesn't get error 'Target row updated by multiple source rows.' using my examples?
Thanks for the help Fred. It looks like the join with enty_key to alert_id has a varchar to decimal relationship. I just performed a cast to make the join equal. So were right on the money with your answer!