You are on page 1of 4

http://sql-quiz.sampleaptitudequestions.com/sql7.asp What is explain in teradata?

The EXPLAIN facility is a teradata extension that provides you with an "ENGLISH" translation of the steps choosen by the optimizer to execute an SQL statement.It may be used oin any valid teradata database with a preface called "EXPLAIN".<br><br>The following is an example:<br><br> EXPLAIN select last_name,first_name FROM employees;<br><br>The EXPLAIN parses the SQL statement but does not execute it.<br><br>This provides the designer with an "execution stratergy".<br><br>The execution stratergy provides what an optimizer does but not why it choses them.<br><br>The EXPLAIN facility is used to analyze all joins and complex queries. Delete Duplicate Rows From an Oracle Table DELETE FROM our_table WHERE rowid not in (SELECT MIN(rowid) FROM our_table GROUP BY column1, column2, column3... ; When do you use WHERE clause and when do you use HAVING clause? The WHERE clause specifies the criteria which individual records must meet to be selcted by a query. It can be used without the GROUP BY clause. The HAVING clause cannot be used without the GROUP BY clause. The WHERE clause cannot contain aggregate functions. The HAVING clause can contain aggregate functions. The WHERE clause selects rows before grouping. The HAVING clause selects rows after grouping. How to find out nth highest salary from Employee table? SELECT DISTINCT (a.Salary) FROM [Employee] a WHERE nth = (SELECT COUNT (DISTINCT (b.Salary)) FROM [Employee] b WHERE a.Salary <=b.Salary ); What is difference between TRUNCATE & DELETE The Main Difference Between DELETE & TRUNCATE Are :[1] DELETE - is a DML Command & TRUNCATE - is a DDL Command [2] After DELETE - can rollback the Records & After TRUNATE - cannot rollback the records [3] In DELETE Command you can give the conditions in WHERE Clause & In TRUNCATE you cannot give conditions [4] After using DELETE Command The memory will be occupied till the user does not give ROLLBACK or COMMIT & After using TRUNCATE Command The memory realeased immediately select top three max salaried Employee from Employee table ? SELECT DISTINCT (a.Salary) FROM [Employee] a WHERE 4 > (SELECT COUNT (DISTINCT

(b.Salary)) FROM [Employee] b WHERE a.Salary <=b.Salary ) how to delete duplicate records from Teradata table? delete from Employee where ROWID = ( select ROWID from ( SELECT ROWID,ROW_NUMBER () OVER ( PARTITION BY Employeeid,Salary ORDER BY Employeeid) AS Rownum,Employeeid,Salary FROM Employee ) A where A.rownum > 1 ) When do you use WHERE clause and when do you use HAVING clause? The WHERE clause specifies the criteria which individual records must meet to be selcted by a query. It can be used without the GROUP BY clause. The HAVING clause cannot be used without the GROUP BY clause. The WHERE clause cannot contain aggregate functions. The HAVING clause can contain aggregate functions. The WHERE clause selects rows before grouping. The HAVING clause selects rows after grouping. Which is more faster - IN or EXISTS? EXISTS is more faster than IN because EXISTS returns a Boolean value whereas IN returns a value. Fload, Mload and error tables How many error tables are there in fload and what are their significance/use? Can we see the data of error tables? How many error tables are their in mload and what is there use? When mload job fails, can we access mload tables? If yes then how? Fload uses 2 error tables Error table 1: where format of data is not correct. Error table 2: violations of UPI Error table1: Contains one row for each row which failed to be loaded due to constraint violations or translation errors Error table2: For non-duplicate rows captures those rows that cause a UPI duplicate violation. Mload also uses 2 error tables (ET and UV), 1 work table and 1 log table 1. ET TABLE - Data error MultiLoad uses the ET table, also called the Acquisition Phase error table, to store data errors found during the acquisition phase of a MultiLoad import task. 2. UV TABLE - UPI violations MultiLoad uses the UV table, also called the Application Phase error table, to store data errors found during the application phase of a MultiLoad import or delete task 3. WORK TABLE - WT Mload loads the selected records in the work table 4. LOG TABLE A log table maintains record of all checkpoints related to the load job, it is essential/madatory to specify a log table in mload job. This table will be useful in case you have a job abort or restart due to any reason. CAN ANY ONE SEND ME THE CODE FOR THE BELOW 1).REMOVE '_' FROM TELE PHONE "323-237-2323" AND SHOULD DISPLAY OUT PUT AS "323237232" 2). NEED TO ONLY "COMPANY.COM" FROM EMAIL FILED "TEST@COMPANY.COM"

Use trim(columnname,'_','a') to remove the '-' values from the columns substr('TEST@COMPANY.COM',instr('TEST@COMPANY.COM','@')+1) What's the difference between dimension tables and fact tables? These two table types are used in what we call star schemas; these are used for analysis rather than capturing transactions. What is the difference between dimension tables and fact tables? One very literal (and initially unhelpful) answer is that fact tables store facts. Happily, this definition is only unhelpful until we add an example. Suppose our company sells products to customers. Every sale is a fact that happens within our company and the fact table is used to record these facts. Fact table TimeID ProductID 4 17 2 8 21 3 8 4 1 CustomerID 1 2 1 Unit Sold

Now we can add a dimension table about customers: Dimension table: Customers CustomerID Name 1 Brian Edge 2 Fred Smith 3 Sally Jones Gender M 2 M 3 F 1 Income 3 5 7 Education 4 1 3 Region

By following the links we can see that, for example, row 2 in the fact table records the fact that customer 3 (Sally Jones) bought two items on day 8. And, in a complete example, we would also have a product table and a time table so that we know what she bought and exactly when. The fact table lists events that happen in our company (or at least the events that we want to analyze). The dimension tables list the factors (Customer, Time, Product) by which we want to analyze the data. Given this fact table and these three dimension tables, we can ask questions like: How many diamond rings have we sold to female customers in region 4 during the first quarter of 2008? In other words, the difference between dimension tables and fact tables is that fact tables hold the data we want to analyze and the dimension tables hold the information necessary to allow us to query it.

You might also like