2528 | 20 Jan 2014 @ 11:53 PST | Analytics | Reply | Transpose rows to columns | Hi Cheeli,
select
min(case when sales_month = 'jan' then sales_amnt else 0 end) as jan,
min(case when sales_month = 'feb' then sales_amnt else 0 end) as feb,
...
min... |
2527 | 20 Jan 2014 @ 08:29 PST | Analytics | Reply | multiple join in sub quary | When i try to explain my query it fails with a "table not found", which means it's syntactically correct.
Btw, line 60 is commented out in my query, did you run this or your original... |
2526 | 20 Jan 2014 @ 07:13 PST | Database | Reply | Convert Teradata Mode Procedure to ANSI Mode | ODBC Options: Session Mode
Or within the connection steing: SessionMode=ANSI
|
2525 | 20 Jan 2014 @ 06:40 PST | Database | Reply | Cast-DATE | Hi Sri,
use your existing calendar or the built-in sys_calendar to calculate all possible values for your expected date range and then [left] join to it:
SELECT
(EXTRACT(MONTH FROM calenda... |
2524 | 20 Jan 2014 @ 12:03 PST | Database | Reply | Cast-DATE | a11.XYZ_SK is an INTEGER column with YYYYMMDD, e.g. today is 20140120.
Substracting 19000000 results in an INTEGER with Teradata's internal date representation: 1140120
And th... |
2523 | 19 Jan 2014 @ 11:54 PST | Database | Reply | Inserting into a timestamp(6) column | If you're on TD14 you can use TO_TIMESTAMP, which is a bit more flexible than Teradata's FORMAT:
TO_TIMESTAMP(dt, 'YYYY-MM-DD-HH24:MI:SS:FF6' )
|
2522 | 19 Jan 2014 @ 02:50 PST | Database | Reply | How to transpose rows to columns without the use of .sql and Bteqs |
SELECT
WUNO,
MAX(CASE WHEN rnk = 1 THEN x ELSE '' END)
|| MAX(CASE WHEN rnk = 2 THEN '_' || x ELSE '' END)
|| MAX(CASE WHEN rnk = 3 THEN '_' || x E... |
2521 | 19 Jan 2014 @ 02:39 PST | Tools | Reply | FastExport script and output delimiters | Hi Prashant,
this has been discussed several times, the best solution is to switch to TPT, the latest versions can directly export delimited data without need for TRIM/concat.
Otherwise the "... |
2520 | 19 Jan 2014 @ 02:36 PST | General | Reply | dupliacate rows | These are no duplicate rows. You probably have some rows violating your Primary Key, but i don't have a clue about your rules why it's wrong and how to fix it
|
2519 | 19 Jan 2014 @ 02:34 PST | Database | Reply | Issue with TIME(6) datatype field in Teradata | Hi Ramkumar,
this is a known problem due to some settings in the ODBC driver. There are several solutions:
#1: in older versions of SQL Assistant there's "Allow Use of ODBC SQL Exte... |
2518 | 18 Jan 2014 @ 08:32 PST | Database | Reply | Join tables and replalace NULLS | Try this:
SELECT
tab.*,
MIN(tab2.Manager)
OVER (PARTITION BY tab.CustId
ORDER BY tab.MonthID
RESET WHEN tab2.Manager IS NOT NULL
ROWS UNBOUNDED PRECE... |
2517 | 17 Jan 2014 @ 01:22 PST | Database | Reply | Find usage | PMon data is always snapshot data.
You might find historical data within DBQL, but Viewpoint should be the easiest way to find resource intensive queries using the Query Spotlight portlet.
|
2516 | 17 Jan 2014 @ 12:36 PST | Database | Reply | How to grant a role to public | Trying to grant a role to public should return an error message.
Public is a role and it's always active for every user.
So simply grant the right directly to public.
|
2515 | 17 Jan 2014 @ 09:58 PST | Analytics | Reply | multiple join in sub quary | Seems you did some modifications of Derived Tables resulting in too many ')', easy to spot when you format the SQL:
SELECT
MIN(trs_dt)
,MAX(trs_dt)
,COUNT(DISTINCT a.cus_ian_... |
2514 | 17 Jan 2014 @ 09:29 PST | Database | Reply | Find usage | You can easily sort the Query Portlet in Viewpoint by CPU-Delta.
If you want to write a query do that on your own there's the SQL PMon API, e.g.
SELECT 100 * AvgAmpCPUSec / SUM(AvgAmpCPUSec... |
2513 | 17 Jan 2014 @ 12:24 PST | Database | Reply | AGGREGATION | What are you trying to achieve?
Any column which is not part of the GROUP BY must be used within an aggregate function.
Without showing the actual query it's hard to tell what's wro... |
2512 | 16 Jan 2014 @ 01:09 PST | Database | Reply | How to use regex in Teradata or 'LIKE' operator in teradata | Hi Raja,
this will fail for data like '1a1'.
Using a regular expression it's:
WHERE REGEXP_SIMILAR(id, '[0-9]+', 'c')=1
|
2511 | 16 Jan 2014 @ 12:55 PST | Database | Reply | How to grant a role to public | What exact error is returned?
For SPs there's a SECURITY option either CREATOR/DEFINER/OWNER or INVOKER.
You should check the DDL manual which one you actually need.
|
2510 | 15 Jan 2014 @ 02:41 PST | Database | Reply | Account balance SQL | Do you need this for a single account or multiple accounts?
What's your TD release?
|
2509 | 15 Jan 2014 @ 12:58 PST | Database | Reply | Date Conversion | It's FORMAT 'ddmmmyyyy'
|
2508 | 15 Jan 2014 @ 12:52 PST | Database | Reply | Getting week of the year from a date | You should change the calculation to the ISO calendar:
TD_SYSFNLIB.WEEKNUMBER_OF_YEAR (CURRENT_DATE, 'ISO')
And you probably need the ISO-year, too:
YEARNUMBER_OF_CALENDAR(current_da... |
2507 | 15 Jan 2014 @ 12:38 PST | General | Reply | Omit Rows From Table | Based on your description this sounds like a simple Inner Join.
You should give more details, maybe some rows plus estimated result.
|
2506 | 14 Jan 2014 @ 02:33 PST | Database | Reply | SELECT MAX(timeValue), MIN(timevalue) FROM OurDB.DimTime - Returns wrong result | Your session timezone is set to -6, try
SELECT timeValue AT 0 FROM OurDB.DimTime ORDER BY 1
SQL Data Manipulation Language
Chapter 1: The SELECT Statement
ORDER BY Clause
Unexpected Sort ... |
2505 | 14 Jan 2014 @ 10:57 PST | Database | Reply | SQL help | ROWS 3 PRECEDING is equivalent to ROWS BETWEEN 3 PRECEDING AND CURRENT ROW.
Simply move the functions as columns into the SELECT and check the result :-)
|
2504 | 12 Jan 2014 @ 04:09 PST | Database | Reply | Way to optimize query for bigdata processing | As you access two months of a table partitioned by day why don't you simply process all the rows for a single day = 59 batches?
This will return all batches in one query, but it mig... |