853 | 21 Dec 2010 @ 11:36 PST | Database | Reply | Joins on columns | Where do you get that data from?
Your data source should provide usefull data, not that kind of garbage.
The only way to achieve your desired result using SQL is to split that string into rows ... |
852 | 21 Dec 2010 @ 01:46 PST | Database | Reply | How to use LIKE in queries | Tablename is a CHAR(30) and any comparison using LIKE does *not* append trailing blanks like "=" etc.
Two possible solutions come to mind:
- TRIM(tablename) like '%\_L' ESCAPE '\';
- when you'... |
851 | 15 Dec 2010 @ 01:34 PST | Database | Reply | How to dynamically pass values to SQL ? | If you're supposed not to write an SP, you should tell your boss/dba, that this is foolish.
Of course you can write some BTEQ scripts to create and run the neccessary SQL, too, but this is more ... |
850 | 08 Dec 2010 @ 09:05 PST | Database | Reply | Implicit conversion CHAR to INT failing | In fact it's used correctly :-)
You get an automatic typecast (= Teradata style typecast), which uses the format of the column, which is right aligned within 11 characters, i.e. leading blanks.
... |
849 | 01 Dec 2010 @ 02:17 PST | Database | Reply | Execute Macro from Stored Procedure??? | Hi JK,
the DECLARE CURSOR(MACRO) is only for Embedded SQL, but not SPs.
You can call an SP from a macro, but not vice versa.
Dieter
|
848 | 18 Nov 2010 @ 01:04 PST | Database | Reply | error: bad argument for sqrt function | If sqrt(abs(...)) work then you definitely got negative values.
Remove the sqrt and check for it.
FLOAT is a 8 byte IEEE floating point format with approximately 15/16 digits precision, whereas... |
847 | 17 Nov 2010 @ 10:28 PST | Database | Reply | error: bad argument for sqrt function | Hi Carlos,
the query fails even if you use BIGINT instead of BYTEINT :-)
Remove the SQRT and see the negative value.
This looks like a part of a standard deviation calculation, in that case th... |
846 | 17 Nov 2010 @ 07:02 PST | Database | Reply | Statistics on Primary Index | I use this is for missing stats on any PI/SI, you could add filter for PIs only.
I'm shure it can be further simplified, as it was created based on a query solving a different problem :-)
/**... |
845 | 17 Nov 2010 @ 06:49 PST | Database | Reply | error: bad argument for sqrt function | Strange.
I would suggest to run that query from BTEQ or any other query tool, maybe it's because of a SQLA/ODBC/.NET "feature".
To eliminate issues with SQRT you could replace it with (a-b)**... |
844 | 17 Nov 2010 @ 05:41 PST | Database | Reply | error: bad argument for sqrt function | Is this the error?
2604 Bad argument involving ... for SQRT function.
First try adding a condition to see if actually a >= b:
WHERE a >= b
Do you run that query in SQL Assistant pre-TD13?... |
843 | 14 Nov 2010 @ 01:18 PST | Database | Reply | Large History Table Design using PPI | Why separate tables?
As long as the optimizer is able to eliminate partitions based on the WHERE-condition, there is no reason to create seperate tables.
And if the typical date range queried i... |
842 | 14 Nov 2010 @ 01:07 PST | Database | Reply | Is it possible to convert to a date interval string literal to be used within a select? | You were quite close:
SELECT DATE '2004-12-15' + ((DATE'2005-02-01'- DATE'2004-01-01') MONTH);
You can't construct an interval the way you did, you have to cast:
SELECT DATE '2004-12-15' + C... |
841 | 09 Nov 2010 @ 12:47 PST | Database | Reply | Solving a problem without using an OLAP function | Hi Kevin,
it's still confusing.
You want all rows where test_time is not null plus the row where there's only a NULL for a (person_name,test_date) combination, is that correct?
You could wri... |
840 | 08 Nov 2010 @ 09:31 PST | General | Reply | Teradata variable/view/macro | You mean the Where-condition "WHERE col1 = '123'" is stored as a string in col3?
This needs Dynamic SQL which is only possible within a Stored Procedure.
How does col4 actually look like?
Is ... |
839 | 08 Nov 2010 @ 08:17 PST | Database | Reply | Case When Statement in Teradata | Your join returns two rows, because two rows match.
A CASE statement in the SELECT list will never filter any rows.
Logically there's the JOIN* first, followed by WHERE*, GROUP BY, HAVING*, OLA... |
838 | 08 Nov 2010 @ 07:00 PST | Database | Reply | Case When Statement in Teradata | HI Janaki,
it's not the CASE, it's the JOIN which creates too many rows.
If you remove the CASE the number of rows shouldn't change, you probably need a ROW_NUMBER to implement that "best fit".
... |
837 | 08 Nov 2010 @ 05:42 PST | Database | Reply | Case When Statement in Teradata | Hi Janaki,
this is confusing me, you write "In my select clause,i have a case statement " but then "I am getting more than one row".
CASE returns a scalar value, it will never change the number... |
836 | 05 Nov 2010 @ 07:12 PDT | Database | Reply | Dynamic Date Calculation in SQL Query | Hi Carlos,
try that query two months later :-)
Dieter |
835 | 04 Nov 2010 @ 10:46 PDT | Database | Reply | Dynamic Date Calculation in SQL Query | You have to play around with ADD_MONTHS and EXTRACT.
d - (EXTRACT(DAY FROM d) - 1) returns the first day of the current month and ADD_MONTHS adds or substracts some months:
SELECT CURRENT_DAT... |
834 | 01 Nov 2010 @ 09:05 PDT | Database | Reply | Numeric overflow....2616 | Hi Rob,
the keyword is probably "backward compatibility".
Most customers don't like it, if any defaults change:-(
Dieter |
833 | 01 Nov 2010 @ 07:26 PDT | UDA | Reply | alter table modify primary index to unique primary index | There's no reason to copy to a new table.
Simply add a USI on the NUPI columns and then
ALTER TABLE xxx MODIFY UNIQUE PRIMARY INDEX (NUPI_cols)
This also drops the USI automatically.
Dieter |
832 | 01 Nov 2010 @ 07:14 PDT | Database | Reply | Numeric overflow....2616 | The manuals clearly state the resulting datatype for a COUNT.
ANSI mode: DECIMAL(15,0) or DECIMAL(38,0), depending on the MaxDecimal setting in dbscontrol.
Teradata mode: INTEGER
Dieter |
831 | 18 Oct 2010 @ 05:36 PDT | Database | Reply | Why do we need integer datatypes | Hi Manu,
the maximum to be stored for 2 byte integer is 127, so in theory this could be stored in a dec(2,0), but 127 are 3 digits and and dec(2,0) only defines 2 digits, so 127 simply doesn't fit... |
830 | 18 Oct 2010 @ 12:45 PDT | General | Reply | Different results in bteq and sql assitant for current_date with format option | Hi Sakthi,
there's no setting in SQL Assistant to achieve the same result.
FORMAT was used for BTEQ reports, which uses CLI and requests the result as a formatted string
If you want to get the... |
829 | 18 Oct 2010 @ 12:31 PDT | Teradata Applications | Reply | Questioning the results of a Window Remaining Function | Is this actually the query you're running?
This should result in a syntax error, because ORDER BY must be after PARTITON BY?
And if you submit that "remaining window" without final ORDER BY t... |