You are on page 1of 7

SQL Questions:

Duplicate query :
Select count (id) as count from table group by id having count >1;

Dense Rank query :


Select dense_rank() over (order by sal ) sal from table where sal = 4;
00
Rank query :
Select Rank () over (order by id ) rank from table where rank =1;

Row number() :
SELECT ROW_NUMBER() OVER(ORDER BY name ASC) AS Row#,
name, recovery_model_desc
FROM sys.databases
WHERE database_id < 5;

SELECT
ROW_NUMBER() OVER(PARTITION BY recovery_model_desc ORDER BY name ASC)
AS Row#,
name, recovery_model_desc
FROM sys.databases WHERE database_id < 5;

Aggregate functions or Group functions : works on multiple rows )


Avg ()
Sum ()
Min ()
Max ()
Count ()

Scalar functions: (Single row )


Upper (‘abcd’) =ABCD LPad (‘ABCD’,’6’,’xxxx’)=xxABCD

Lower (‘ABCD’)=abcd RPad (‘ABCD’,’6’,’x’)=ABCDxx


Initcap (‘abcd’)=Abcd Trim ()
Length (‘abcd’)=4 SubStr (‘First_name’,0,5)=First_
Concat ()
Normalization: Optimising /decomposition of tables to avoid redundancy(duplicates) and
anomalies (add delete update flaws)
1NF - removing repeating groups
2NF - remove partial dependency
3NF - Remove transitive dependency
BCNF - Make sure determinants are candidate keys
4NF - remove multi-valued dependency
5NF - remove join dependencies

Delete V/S Truncate: both used to erase data in a table


Delete have back up and slow
Truncate is fast and no backup

Unique V/S Primary key :


A unique key allows null
The primary key doesn’t allow

common rec b/w 2 taBLES : Table 1 intersect Table 2


SELECT column1
FROM table1
INTERSECT
SELECT column1
FROM table2

alternative records in a table

union /union all : Union all recds of both the quries or tables with out duplicates
Union all with duplicates

first 5 char : Substr (name,1,5)

ETL questions:
ODS operational data staging : intermediate staging area which has integrated data from
different sources.
Staging : intermediate area used for ETL process
View: View is a virtual model or subset of the tables without showing complete details and
hiding the relations and other technical details for Security or for only read operations

Slowly Changing Dimensions:


Type 0: Not updating even if there’s a change because it’s not needed anymore. Eg: Fax
Type 1: overwrite or Update the existing attribute (History is not saved ) Eg Dollar value
Type 2: Adding a new row altogether (no of rows increases thus less efficient) eg :
Add Flag (Valid/Invalid) or From and To date
Type 3: Add an additional column in the same row (effective) eg designation, location
Prev location - Current location
Type 4 : Maintaining a History separate table for analysis eg : Share market

Different checks in ETL data:


Index check
Constraints check
Table structure verification
Source data validation
Data count check
Records check
Data comparision
Duplicate check
Null check
Date format
Upper lower case
scale precision

Different types of errors:


Missing data
Incorrect transformations
Data truncation
Data type mismatch
Duplicates

Calculation errors:
ETL Job running commands:
Unix commands :
LS list
Grep Search for a char or word
Cd open the directory
Sh run shell script
Cp copy

How to compare data from CSV to JSON :

Stored procedure :
Triggers:
Data mart : A data mart is a subset of a data warehouse focused on a particular line of
business, department, or subject area.

Data Model: Logical high-level structure of the DB or company.


Conceptual, logical, physical data models.
Data warehouse: combines data from multiple sources into one place for analytical
purposes.
Meta data : DESC table_name;
Fact: main centre table which is connected to all the tables and contains only PK’s of other
tables
Dimension : A table which is connected to a fact table

Schema : collection of tables and their relationships

Star schema : a single fact is connected to dimensions


Snowflake: a schema where dimension tables also acts as facts

Different tables in data migration:


OLTP online transaction process
Day to day daily transactions
Normalization
raw data
OLAP: online analytical process
Old legacy data
DeNormalized
Data warehouse
Used for analytical

Data purge : Deleting very old data


Data archive : hiding data

CASE :
Case (
If (select id from emp where sal is null)
Then id
Else ‘2’) as id;
1.Count the total number of employees having a salary more than 10000.
Select count(EMPID) from table WHERE sal >10000

 2.How to select latest transaction in SQL?

 3. Third highest salary of the employee working in Testing Dept.


SELECT RANK () OVER (ORDER BY (ID)) RANK ,sal FROM TABLE WHERE RANK = 3;

 4.Display either first  or last 50 records in employee Database.


Select top 50 from emp ;
 5.How to delete duplicate rows in a table? 

6.Count the total salary department  wise where more than 2 employees exist.
Select count (deptid)dpt,sum (sal) from table group by deptid having dpt >2;
 7.Difference between drop,delete and truncate  with each SQL query example  and
explanation

 8..Difference between group by, where and having clause with query example. 
Select id from table group by id having sal >1000;
Select id feom table where id=! 5 group by id;
9. Prepared and run SQL queries to verify Dimension and Fact tables.

Testing
STLC
Bug Lyf Cycle
Types of Testing : Integrated,functional,API
RTM
Exit and entry crieteri
DEFERRED

Agile
Sprint Retrospective :
Sprint Review :
Sprint panning :
Prd backlog :
Sprint backlog:
Scrum master :
Product owner :
Scrum

You might also like