ReadVitamin

Blogging on Teradata SQL and More

5 Comments

mygif
Said in Saturday, August 25th, 2007 @4:50 pm  

The scripts did not work for me initially; I had to create MULTISET table as I was getting error due to duplicates… Is TD checking only PRIMARY INDEX value or whole row?

I got this when I created SET table:
Code = 2802.
Statement 1 - 2802: Duplicate row error in RSTANA.sales.
Output directed to Answerset window

changing table to MULTISET worked

When are you getting those useful info? I am new to TD and hungry for info. Thanks for useful blog! Keep it up!

mygif
Said in Saturday, August 25th, 2007 @4:53 pm  

one more note:

Particularly for the store number 30, you can see that there is a slight increase in the moving average in spite of good increase in actual sales.

sounds incorrect; I would say there is a [b]decrease[/b] in moving average despite increase in actual sales

mygif
Said in Monday, August 27th, 2007 @4:51 pm  

Hi Rastislav,

Thank you for leaving a reply.

First let’s see what are SET and MULTISET.

These two claues are used to create Table in Teradata with characterstics to
allow duplicate or not. If you specify SET, which adheres to relational data model,
it will not permit duplicate rows in a table. On the other hand, MULTISET tables
follows multidimensional data model and allows duplicate rows in a table.

So what happens if you do not use either….it depends on the session.

If your current session is ANSI, then by default clause would be SET.
Otherwise if the session is Teradata, the default clause would be MULTISET.

Secondly, regarding “increase in the moving average”.

When I said increase, I meant increase from last month. As you see the actual sales in Feb’07
is 10,000 and the moving avg is 10,250 and the following months have 10,500 and 12,500 as actual sales and the MAVG is 10,500 and 11,250 respectively. As I have ordered the result set by “projected sales”
the figures are a bit confusing. But I appreciate your minute observation. Ordering the results with “sale month” as in the following query, would give a clear picture. Hope this helps.

SELECT store_no, sale_month, actual_sale, projected_sale,
AVG(actual_sale) OVER (PARTITION BY store_no
ORDER BY sale_month
ROWS 1 PRECEDING)
FROM sales;

mygif
Said in Tuesday, August 28th, 2007 @8:38 am  

How do I know if my session is ANSI or Teradata? Is there a way to change it? (ALTER SESSION or sthg. similar?)

mygif
Said in Tuesday, August 28th, 2007 @11:28 pm  

Check with the ‘help session’ command
and look for the value of
Transaction Semantics.

Leave Your Comments Here

Popular Articles