Top Questions - TeradataQuestions most recent 30 from http://teradataquestions.com 2010-03-11T18:57:43Z http://teradataquestions.com/feeds http://www.creativecommons.org/licenses/by-nc/2.5/rdf http://teradataquestions.com/questions/76/how-to-split-one-column-data-into-multiple-columns How to split one column data into multiple columns guest 2010-02-19T23:34:20Z 2010-03-11T17:04:56Z <p>How to split one column data into multiple columns using Teradata sql-assistant?</p> <p>For example: I have a table “T1” which has only one column C1 varchar (100) and it has pipe delimited “|” value like this:</p> <p>XYZ|ABC|DEF|1234|WER|QWE</p> <p>I have other table “T2” which has 6 columns. I want to read data from table T1, split it and load into T2 (in all 6 columns).</p> <p>I will appreciate your help. Thanks</p> http://teradataquestions.com/questions/88/get-rid-of-zeros-after-decimal-point get rid of zeros after decimal point sam 2010-03-10T18:38:14Z 2010-03-10T19:41:12Z <p>Hi All,</p> <p>select CAST(MIN(column_1) AS DECIMAL(10,2)) Days from tale_1</p> <p>I get output as 13.09 13.30 31.00</p> <p>Can anybody let me know how to get rid of the zero after the decimal point I need output as 13.09 13.3 31</p> <p>REgards,</p> http://teradataquestions.com/questions/87/retention-of-data-in-dbc-dbcassociations Retention of data in DBC.DBCAssociations Rob Paller 2010-03-08T19:47:13Z 2010-03-08T19:47:13Z <p>This table is used to support the migration of objects between Teradata installations using the ARCMain tools (COPY/RESTORE) and provide a mapping of the old object id's to the new object ids. However, I am seeing that it can also lend itself to being a point of contention with BAR activities running concurrently with ETL activities.</p> <p>How long does the data in DBC.DBCAssociations need to remain? </p> <p>If the objects have been archived on the destination system at least one time after being copied from the source system is the link still relevant? </p> <p>Is the link their for subsequent migrations of the object from the source to the target system?</p> http://teradataquestions.com/questions/18/6760-invalid-timestamp 6760 Invalid timestamp TDHelp 2009-10-27T07:02:47Z 2010-03-05T18:22:34Z <p>Hi,</p> <p>I am trying to update the timestamp into a table like this:</p> <pre><code>Update tablea set status = 'Succeeded', end_date = cast(cast(current_timestamp(0) as format 'dd/mm/y4bhh:mi:ss') as char(19)) where id = 3456; </code></pre> <p>I am getting Invalid timestamp for this query. When I check the timestamp data through select it looks like this:</p> <pre><code>select cast(cast(current_timestamp(0) as format 'dd/mm/y4bhh:mi:ss') as char(19)) </code></pre> <p>Resultset:27/10/2009 02:56:12</p> <p>I want to update the end_date through current_timestamp not by putting timestamp value in it.</p> <p>Please help me in this. Thanks and Regards, TDHelp</p> http://teradataquestions.com/questions/51/order-by-issues order by issues TDHELP 2010-01-06T07:48:41Z 2010-03-05T01:22:23Z <p>Hi,</p> <p>I need help in order by, I have a subquery which gets this data.</p> <pre><code>pname version count xxx V12.1 1 yyy V22.1.3 1 </code></pre> <p>We are using grouping function and roll up in the main query, the query was written in the following way: </p> <pre><code>SELECT case when grouping(pname) = 1 then 'Total' else case when grouping(version) = 1 then 'Subtotal ' || pname when RANK() over (partition by pname order by SUM(count)) = 1 then pname else ' ' end end "NAME", version "VERSION", SUM(count) "Qty" FROM ( SELECT pname, version, 1 count from tablea, tableb, tablec where tablea.key = tableb.key and tableb.key = tablec.key --order by pname, version (ghis order by worked in oracle , but does not work in TD because order by does not work on subquery) )as derived_table GROUP BY rollup (pname,version) </code></pre> <p>With this query, the resultset comes in the following way:</p> <pre><code>NAME VERSION QTY Total ? 2 Subtotal XXX ? 1 XXX V12.1 1 YYY V22.1.3 1 Subtotal YYY ? 1 </code></pre> <p>When compared to oracle the data looks good, but the records are not ordering properly. The actual output should come like this:</p> <pre><code>NAME VERSION QTY XXX V12.1 1 Subtotal XXX ? 1 YYY V22.1.3 1 Subtotal YYY ? 1 Total ? 2 </code></pre> <p>Could anyone help me to display the data in this order. I appreciate your help. Thanks in advance.</p> <p>Regards, TDHELP</p> http://teradataquestions.com/questions/73/teradata-sql-assistant-takes-forever-to-interrupt-large-answerset Teradata SQL Assistant takes forever to interrupt large answerset Carlos A. Ibarra 2010-02-11T03:30:41Z 2010-03-03T20:22:28Z <p>I am using Teradata SQL Assistant version 13.0.0.08 on Windows. I think it's the version written in C#.</p> <p>When I run a query that returns more than 2000 rows, which is my max in the options for rows to display, and it asks me if I want to cancel after 2000 rows and I click Yes, I expect it to immediately give me back control. Instead, it still takes a long time (sometimes minutes) to come back. During this time, SQL Assistant is unresponsive and the query pane background is light red, like it's busy. I have checked the network activity and it appears that the rest of the rows are still being read from Teradata. Very annoying.</p> <p>This happens the same way whether I am using the .Net provider or ODBC to connect to Teradata. I have looked through all the options but nothing seems like it would help. Tomorrow I will try installing a slightly newer version that I think is available.</p> <p>How can I fix this?</p> http://teradataquestions.com/questions/27/least-function-in-td Least function in TD TDHelp 2009-11-10T00:19:44Z 2010-03-03T01:22:23Z <p>Hi,</p> <p>I need help in getting this function,</p> <p>In oracle, least(2, 5, 12, 3) would return 2</p> <p>Do we have similar function in TD or how do we do.</p> <p>Thanks for Regards, TDHelp</p> http://teradataquestions.com/questions/81/how-to-interpret-value-of-field-createdate-in-tdwm-tables How to interpret value of field 'CreateDate' in TDWM tables? Monis Iqbal 2010-03-01T12:32:58Z 2010-03-02T03:21:51Z <p>CreateDate and RemoveDate are two fields in many of the tables related to TDWM e.g. in WlcDefs. The values and their meanings (according to me) are like:</p> <p>1100301 - 2010/03/01 1091114 - 2009/11/14</p> <p>What does the first '1' represent in these date fields? and is my interpretation correct?</p> http://teradataquestions.com/questions/79/does-rollbackprioritytrue-mean-to-use-rush-or-no-rush-for-rollbacks Does RollbackPriority=TRUE mean to use Rush or No Rush for rollbacks? Carlos A. Ibarra 2010-02-26T16:21:58Z 2010-02-27T17:46:36Z <p>This DBSControl setting is supposed to control whether rollbacks run at Rush priority or not. They used to always run at Rush because Teradata wanted to get them out of the way as soon as possible, but later they provided this RollbackPriority DBSControl parameter so the DBA can decide. However, it is not clear whether setting it to TRUE means that the rollback runs at Rush or not. </p> <p>Does TRUE mean that rollbacks run at Rush or that they run at the user's logon priority?</p> <p>The help for this setting is comically ambiguous:</p> <ol> <li>RollbackPriority - This Field defines the system default for the rollback priority. This allows the DBA to either take the default priority of Rush or the user's logon priority. To enable this feature set the field to TRUE. To disable the feature set the field to FALSE. Note that this new feature will affect all users on the system.</li> </ol> http://teradataquestions.com/questions/61/how-to-perform-bit-wise-operations-in-sql How to perform Bit-wise operations in SQL? Monis Iqbal 2010-01-18T09:18:40Z 2010-02-16T12:31:33Z <p>How to perform simple bit-wise operations like OR (|), AND (&amp;), XOR (^) in SQL queries?</p> <p>Can these be performed on numeric values? like</p> <pre><code>sel 1 | 2; </code></pre> http://teradataquestions.com/questions/71/order-by-based-on-case-sensitivity Order by based on case sensitivity sam 2010-02-10T23:55:31Z 2010-02-15T21:43:31Z <p>Hello All ,</p> <p>Is there any way to sort the column data based on case sensitivity. How can I do order by if I want to display the UPPER CASE data first of same order first and then the lower case .</p> http://teradataquestions.com/questions/68/decode-with-rownum Decode with Rownum TDHelp 2010-01-26T20:31:10Z 2010-01-28T12:18:35Z <p>Hi,</p> <p>I have a requirement in Oracle using Decode function with Rownum. I need to convert this into Teradata. I need help in this. I tried using Top function and Rank qualify but unable to do the same. Please help me in this.</p> <p>sample query in Oracle is:</p> <pre><code>SELECT DECODE(ROWNUM, 1, party, 2, party, 3, party, 4, party, 5, party,6, party, 7,party,'Others') party, mnth,SUM(qty) FROM ( SELECT NVL(trim(b.Party_name),'Others') party, c.MONTH_ID mnth, SUM(a.qty) qty FROM tablea a,tableb b,tablec c WHERE a.col1 = b.col1 AND a.col2 = c.col1 AND a.col3='Y' GROUP BY party,mnth ORDER BY SUM(a.qty) DESC ) GROUP BY DECODE(ROWNUM, 1, party, 2, party, 3, party, 4, party, 5, party, 6, party, 7, party, 'Others'),mnth </code></pre> <p>Please help me the conversion of outer query in Teradata. Thanks in Advance.</p> <p>Thanks and Regards, TDHelp.</p> http://teradataquestions.com/questions/48/difference-between-filepres-and-fileprereads Difference between FilePres and FilePreReads Monis Iqbal 2009-12-21T07:24:02Z 2010-01-26T18:16:51Z <p>From Teradata documentation, the definitions of these ResUsageSpma columns are:</p> <pre><code>FilePres Total number of times a cylinder is loaded. FilePreReads Number of times a cylinder is loaded. </code></pre> <p>which look similar, but I observed on our lab's Teradata and found quite different values with an observation that FilePres = 2 x FilePreReads (approx.)</p> <p>I also looked into KA but couldn't find any explanation. Please respond if you know the meaning of these fields.</p> <p>The story doesn't end here. When I compared different versions of Teradata documents (V2R6, 12, 13) I found out quite a few differences among them.</p> <p>The screenshots of the differences (from Excel) are attached. <img src="http://farm3.static.flickr.com/2783/4210487465%5Fab87b30768%5Fo.jpg" alt="alt text" /> <img src="http://farm3.static.flickr.com/2540/4210487527%5F36c560acb6%5Fo.jpg" alt="alt text" /></p> <p>Any idea on differences or this maybe a Teradata documentation problem?</p> http://teradataquestions.com/questions/63/timestamp-difference Timestamp difference TDHelp 2010-01-21T19:17:39Z 2010-01-22T14:15:56Z <p>Hi Experts,</p> <p>Need help here. In Oracle when we do timestamp difference. The resultset would be days and with some decimal numbers. For Eg.</p> <pre><code>SELECT '03.12.2004:10:34:24' "Now", TO_CHAR(hiredate,'DD.MM.YYYY:HH24:MI:SS') "Hiredate", TO_DATE('03.12.2004:10:34:24','DD.MM.YYYY:HH24:MI:SS') - hiredate "Hired since [Days]" FROM emp; Now Hiredate Hired since [Days] ------------------- ------------------- ------------------ 03.12.2004:10:34:24 17.12.1980:00:00:00 8752.44056 </code></pre> <p>In the above example, we get 8752.44056 as answer. In that, '8752' is no. of days and want to know what is '44056' the precision values,</p> <p>I want to do the same difference in teradata, I am able to get the no. of days but do not know how to get the precision values. I need the same format in teradata. Please help me in this. Thanks in advance.</p> <p>Regards, TDHelp </p> http://teradataquestions.com/questions/64/blank-column-title Blank Column title TDHelp 2010-01-21T19:43:46Z 2010-01-22T02:38:34Z <p>Hi,</p> <p>I need help in not displaying the column title in the select list.</p> <p>For eg: in Oracle </p> <pre><code>select 'abc' as " " from dual </code></pre> <p>we get abc with blank column name</p> <p>In teradata we are not able to do this. Want to know is there a way to do this. Please help me.</p> <p>Regards, TDHelp</p> http://teradataquestions.com/questions/11/oracle-update-to-teradata-update-with-select-subquery Oracle update to teradata update with select subquery unknown (google) 2009-10-20T23:37:13Z 2010-01-20T04:12:38Z <p>Here is the oracle query .Can anybody give me teradata query .</p> <pre> update table_a A set display_format = nvl((select prop.propvalue from table_a B, table_c C where B.request_ID = A.request_ID and B.report_Name = A.report_name and B.report_type = A.report_type and C.systemname = 'system' and C.propname = B.report_name || '.' || B.report_type || '.OutputFmt' and C.PROPVALUE in ('yes','No') ), display_format) where request_id = 123 </pre> <p>Regards,</p> http://teradataquestions.com/questions/59/how-to-yield-maximum-decimal-digits-from-a-cast How to yield maximum decimal digits from a cast? Monis Iqbal 2010-01-13T11:49:49Z 2010-01-13T23:25:18Z <p>I want to demonstrate the problem with the help of an example.</p> <p>Accurate division: 7299 / 48 = 152.0625 However, in Teradata all precision is lost when querying for select 7299/48 = 152</p> <p>We have to apply a cast for precision, like: select cast(7299/48 as decimal(8,5))</p> <p>Assuming that my data column has a length of 8. Here I cannot provide value greater than 8 in the first argument. In the second argument (number of digits after decimal point), at max I can provide 5 because the result yields 3 digits in the numeric part and as a remainder we get 5 (8-3).</p> <p>I'm asking this because I can go into troubles if I apply the same cast to: select 72990/48 = 1520.625 because here the numeric part has 4 digits and I can only supply 4 in the second argument.</p> <p>Is there a way that I can specify only the first argument 8 (equaling to the length of the column) and get the result with complete precision?</p> http://teradataquestions.com/questions/53/rounding-increase-by-1 Rounding increase by 1 TDHELP 2010-01-07T22:26:09Z 2010-01-13T10:03:42Z <p>Hi,</p> <p>I need help in Rounding,</p> <p>value >5 increases to 1.</p> <p>Eg: 72.70 should Round to 73.0</p> <p>Could anyone please help me.</p> <p>Thanks in Advance. TDHelp</p> http://teradataquestions.com/questions/56/query-in-select-list query in select list TDHELP 2010-01-08T00:23:20Z 2010-01-08T02:55:26Z <p>Hi,</p> <p>I need help in writing a query in select list, Is this possible in TD. In Oracle we are able to do it. I have a requirement like this:</p> <pre><code>select col1, col2, Round((col2*100.0/**(select count(col4) from tableh group by col)),**999.9) FROM (select col1,count(col2) from tablea, tableb Where tablea.col1 = tableb.col1 and tablea.col2 = tableb.col2 group by col1) </code></pre> <p>Thanks in advance. TDHelp</p> http://teradataquestions.com/questions/45/determine-the-maximum-number-of-awts Determine the maximum number of AWTs Monis Iqbal 2009-12-16T10:03:48Z 2009-12-16T15:06:59Z <p>The default number of AWTs per AMP is defined to be 80. Can this number grow to some larger value than 80 and can we set a threshold (of number of AWTs) on an AMP level or on Node or System level?</p> <p>Additional note: ResUsageSpma and ResUsageSawt has AwtInuseMax but it does not give us the maximum defined number of AWTs.</p> http://teradataquestions.com/questions/30/update-from-recursive-query UPDATE from recursive query chezakalwe 2009-11-11T13:21:57Z 2009-12-02T12:39:56Z <p>Is it possible to do an update from a recursive query in one SQL statement without using a temporary table?</p> <p>I am trying to set the very top boss id for each employee and I get the error</p> <blockquote> <p>3707: Syntax error, expected something like a name or '(' between '(' and the 'with' keyword.</p> </blockquote> <pre><code>CREATE TABLE EMP(ID INTEGER, BOSS_ID INTEGER, TOP_BOSS_ID INTEGER); INSERT INTO EMP VALUES(1,NULL,NULL); INSERT INTO EMP VALUES(2,NULL,NULL); INSERT INTO EMP VALUES(3,1,NULL); INSERT INTO EMP VALUES(4,2,NULL); INSERT INTO EMP VALUES(5,1,NULL); INSERT INTO EMP VALUES(6,2,NULL); INSERT INTO EMP VALUES(7,3,NULL); UPDATE EMP FROM ( WITH RECURSIVE EH(ID,BOSS_ID,SUPER_BOSS_ID,LEVEL) AS ( SELECT ID,BOSS_ID,BOSS_ID,0 FROM EMP UNION ALL SELECT E.ID,E.BOSS_ID,P.BOSS_ID,E.LEVEL+1 FROM EH E JOIN EMP P ON E.SUPER_BOSS_ID = P.ID ) SELECT * FROM EH ) X SET TOP_BOSS_ID = X.BOSS_ID WHERE X.SUPER_BOSS_ID IS NULL AND X.BOSS_ID IS NOT NULL ; </code></pre> http://teradataquestions.com/questions/29/tab-delimited-question Tab delimited question TDHelp 2009-11-11T09:37:51Z 2009-11-27T14:51:58Z <p>Hi,</p> <p>I do not know whether I can ask this question here or not. But I am facing this problem and need help from the experts.</p> <p>I have a table called Properties_tab which contains oracle sql queries like this: Name query sql1 Select * from abc sql2 select col1 "name", col2 "address" from abcd where col3 = 123 Sql3 select col1, nvl(col2,0), col3 from abcde where col4 = 'abcd' </p> <p>The team gave us this data into an excel file for Teradata conversion. we converted into Teradata. After converting I am trying to upload them into the Teradata. I do not want to do an manual update or insertion. I am trying to do in sql assistant- file- Import data. So it is looking for a tab delimited.</p> <p>I tried converting the excel file into tab delimited and it is showing like this. sql1 "Select * from abc" sql2 "select col1 ""name"", col2 ""address"" from abcd where col3 = 123" sql3 "select col1, nvl(col2,0), col3 from abcde where col4 = 'abcd'"</p> <p>and it is inserting with double quotes into the table. I do not want to insert with double quotes in table. Manual inserts works good like this Insert into Properties_tab(name, query) values ('sql3','select col1, nvl(col2,0), col3 from abcde where col4 = ''abcd''')</p> <p>Any help in this would really appreciate to avoid the manual updates or insertion. </p> <p>Thanks and Regards, TDHelp</p> http://teradataquestions.com/questions/39/tdwm-configuration-data-purging-practices TDWM configuration data - purging practices Monis Iqbal 2009-11-19T19:26:42Z 2009-11-24T14:30:44Z <p>Is TDWM configuration data e.g. WlcDefs, RuleDefs, SysCons etc. ever purged? I've noticed that whenever some modification is made in TDWM the old configuration data is kept in the table with the field RemoveDate, RemoveTime. Is this data purged after some configured duration? or is it a common practice to purge this data in the industry?</p> <p>I'm asking this because there are clear instructions about purging the ResUsage and DBQL data in Teradata documents but so far I haven't found anything on TDWM configuration data.</p> http://teradataquestions.com/questions/42/teradata-documentation-online-search Teradata documentation online search unknown (google) 2009-11-23T08:25:38Z 2009-11-23T09:55:42Z <p>Hi, I am new to Teradata and have to very often search for documentation whenever I hit any error. Does Teradata have any online search feature similar to "IBM Infocentre for DB2-(<a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp" rel="nofollow">http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp</a>) " where I can search on any topic and get the exact results easily (not in terms of pdfs)? I do have access to manuals in the form of pdfs but dont find it very user friendly. Appreciate any help on this.</p> http://teradataquestions.com/questions/38/help-writing-a-query-for-historical-disk-space-usage Help Writing a Query for Historical Disk Space Usage jf18338 2009-11-19T16:13:47Z 2009-11-20T13:27:19Z <p>I am trying to write a query that displays a summary of the total disk space used for all databases for each month.</p> <p>The return results should look something like this for 2008:</p> <pre><code> Month Sum(CurntPerm) Sum(PeakPerm) 01 2.3 tb 2.4 tb 02 2.35 tb 2.35 tb 03 2.38 tb 2.5 tb etc................. </code></pre> <p>Is there a table that can be queried for historical disk space information?</p> <p>Thanks, Jennifer </p> http://teradataquestions.com/questions/36/relation-between-priority-scheduler-in-priority-scheduler-administrator-and-the-p Relation between Priority Scheduler in Priority Scheduler Administrator and the Priority Scheduler in TDWM Monis Iqbal 2009-11-16T12:28:32Z 2009-11-17T00:53:36Z <p>In TDWM we have a Priority Scheduler where we can map WD to AG, add new RP, AG etc. The key here is the 'Priority' that maps WD to AG. This 'Priority' can be set in the WD as 'Enforcement Priority' and can be mapped to AG in the Priority Scheduler screen in the TDWM. Uptill here the relation between TDWM's workloads and priority is clear, and this association can be confirmed by observing the SlgPriority field in the TDWM.WlcDefs table.</p> <p>However the 'Priority Scheduler Administrator' shows a different picture of priority and the association between RP, AG, Perf Group, Perf Period looks to be contained in this administrator itself.</p> <p>There seems to be no relation between the priority of these two (TDWM and PSA). Is this designed this way? If so, then what is the purpose of PSA? If not, then how can the priority in TDWM's Priority Scheduler be linked to PSA?</p> <p>Thanks,</p> http://teradataquestions.com/questions/31/reading-dbs-control-values-via-sql Reading DBS Control values via SQL Monis Iqbal 2009-11-12T06:05:10Z 2009-11-12T13:59:40Z <p>To read values in DBS Control we have to execute the DBSControl utility. Is there a way to read these by issuing queries against Teradata database?</p> http://teradataquestions.com/questions/23/timestamp-diff-with-hour4-to-second0 Timestamp diff with HOUR(4) TO SECOND(0) TDHelp 2009-11-03T23:05:48Z 2009-11-05T19:34:58Z <p>Hi,</p> <p>I am having problem in converting timestamp difference in Hour to Second</p> <p>Earlier with timestam columns I get, </p> <pre><code>select (CLOSED_DATE-CREATED_DATE) hour(4) to second(0) from Tablea where id = '12345' </code></pre> <p>Resultset: 955:30:19</p> <p>The values for those two columns are:</p> <pre><code>CLOSED_DATE:2008-06-30 13:50:29 CREATED_DATE:2008-05-21 18:20:10 </code></pre> <p>The same thing if I try with current_date - another date, am getting Invalid operation on an ANSI datetime or interval value</p> <p>and I changed the current_date like this, but still not helping:</p> <p>select ((cast(current_date as timestamp(0)) + ((current_time - time '00:00:00') hour to second))-CREATED_DATE) hour(4) to second(0) from tablea where id = '12345'</p> <p>This is actually, Oracle to Teradata conversion. In Oracle they wrote a user defined function for it. </p> <pre><code>CREATE OR REPLACE FUNCTION GET_TIMESTAMP (vdays IN NUMBER) RETURN VARCHAR2 IS v_timestamp VARCHAR2(50); /* This function takes the input as Number of days e.g 1/2/2.42 etc... and returns HH:mi:ss. */ BEGIN SELECT TRUNC((vdays * 24 * 60 * 60)/(60*60)) || ':' || TRUNC(MOD((vdays * 24 * 60 * 60),(60*60)) / 60) || ':' || TRUNC(MOD(MOD((vdays * 24 * 60 * 60),(60*60)) , 60)) INTO v_timestamp FROM dual; RETURN v_timestamp; END; / </code></pre> <p>Here they are passing the no. of days into the function. In TD, when I tried it with two timestamp columns difference the resultset is good, but with converting something like this, I am having trouble:</p> <pre><code> select Get_Timestamp(NVL(duration,0)+NVL(SYSDATE-CREATED_DATE,0)) from Oracle_Tablea where id = '12345' </code></pre> <p>Resultset in Oracle:12299:3:48</p> <pre><code>Here the values for duration = 21,0779050925926 CREATED_DATE = 6/30/2008 5:50:29 AM SYSDATE-CREATED_DATE = 491,378449074074 </code></pre> <p>Please help me in Teradata. Thanks and Regards, TDHelp</p> http://teradataquestions.com/questions/25/2665-invalid-date 2665 Invalid Date TDHelp 2009-11-04T21:24:16Z 2009-11-05T12:25:44Z <p>Hi,</p> <p>I am trying to insert some date values in a table and getting error: 2665 Invalid Date</p> <p>The format of the date field on the table is "date_1 FORMAT 'DD-MM-YYYY' ". In the file the date is coming over as '1-01-2008' from java. If I try with '01-01-2008', it inserts fine.</p> <pre><code>Insert into Tablea (id,user_id,start_date,end_date) values (176428,'abcd', CAST ('1-01-2008' AS DATE FORMAT 'DD-MM-YYYY'), CAST ('4-04-2008' AS DATE FORMAT 'DD-MM-YYYY')) </code></pre> <p>In Oracle, if we send in this format to_date('1-01-2008','DD-MM-YYYY'), it inserts fine. In Teradata we are getting errors.</p> <p>Any help would really appreciate.</p> <p>Regards, TDHelp</p> http://teradataquestions.com/questions/21/top-function-in-subquery Top function in Subquery TDHelp 2009-10-28T23:15:08Z 2009-10-29T13:20:09Z <p>Hi,</p> <p>I am converting a query from Oracle to Teradata:</p> <p>In oracle, I have rownum function in subquery. and it runs fine there. But in TD I am using TOP function in subquery and it is not supported. Please help me the work around for this.</p> <p>Query in Oracle:</p> <pre><code>Select col1, col2, col3 FROM tablea where col4 in (Select col4 from (Select distinct col4 from tablea order by col4 DESC) Where ROWNUM &lt; 7 ) Order by col1, col2 desc </code></pre> <p>Converted in Teradata, but this is not correct:</p> <pre><code>Select col1, col2, col3 FROM tablea where col4 in (Select TOP7 a.col4 from (Select distinct col4 from tablea) as a order by a.col4 DESC ) Order by col1, col2 desc </code></pre> <p>Please help me the work around for this query.</p> <p>Thanks in advance. Regards, TDHelp</p>