Sampling By Group, TD SQL?

Analytics
Enthusiast

Sampling By Group, TD SQL?

Dear All,

My friend told me this query take from TD document:
*********************************************************
Get a sample which conforms to the following requirements.

33% of people earning less than $30,000
67% of people in the $30,001 - $40,000 range
40% of people in the $40,001 - $50,000 range

--Query--

SELECT employee_number AS empno, salary_amount AS Salamt
FROM employee SAMPLE
WHEN salary_amount < 30000 THEN .33
WHEN salary_amount BETWEEN 30001 AND 40000 THEN .67
WHEN salary_amount BETWEEN 40001 AND 50000 THEN .40
END
ORDER BY 2;
*********************************************************

Actually I have 2 questions:

1) Does above really a TD SQL?
2) If yes, why the query unable to run?

Many Thanks in Advance. ^_^
1 REPLY
Enthusiast

Re: Sampling By Group, TD SQL?

Hi Benjamin See,

I am sure it is an teradata SQL. But why i didn't work for you its a bit tricky. The query given by your friend is correct sql. You try to rerun it incase you are unable run it. Please let us know how you are executing the query. And how many rows does your table employee contains.

thanks