SDSFSD
SDSFSD
result:
ProductID, ProductName, Category, and Discount
102, XYZ, Electronic, 5%
101, ABC, Electronic, No Discount
getdate-yesterdaydate =
with cte as
(
select *, row_number() over (partition by empid order by salary desc) as rnk from
emp
)
Sales
10000
null
null
result:
Write a query to find all transactions that occurred in the last 30 days.
with cte as
select *, row_number() over (partition by empid order by salary desc) as rnk from
emp
where rnk<1
employee_id, salary
10, 1000
20, 2000
30, 3000
40, 5000
Q1. Design a mapping to load the cumulative sumof salaries of employees into
targettable?
Static Cache
Dynamic Cache
Static cache remains same during the session run. Dynamic cache changes during
session run.
We can use other than relational operators like ,= &=.
We can use only = operator with dynamic cache.
We can handle multiple matches in static cache.
We cannot multiple matches in dynamic cache.
Static can be used to relational and flat file lookup types. Dynamic cache can
be used to only relational lookup types.
Static cache can be used to both unconnected and connected lookup transformation.
Dynamic cache can be used to only connetced lookups.
Connected lookup: Receives source data, performs a lookup, and returns data to the
pipeline.
Unconnected lookup: Is not connected to the source or target, and is called by a
transformation in the pipeline by using the :LKP expression. It returns only one
column value to the calling transformation
1.
Nth Salary_____________________
With CTE
as
(
select *, dense_rank() over (Order by salary desc) as RN
)
With Adult
as
(
select *, row_number() over (order by age desc) as RN from details
where category="adult"
)
Child
as
(
select *, row_number()over (order by age desc) as RN from details
where category ="child"
)
select a.name as Adult, c.name as Child
from adult a
left join child c
on a.RN=c.RN
________________________________________________
Sequence Puzzle
with Cte
as
(
select *,row_number() over (partition by name order by sequence) as RN,
sequence - row_number() over (partition by name order by sequence) as RNG from
sequenceData
)
cte1
as
(
select name, RNG,min(squence) as Minv, max(sequence) as MaxV
from cte
group by Name , RNG
)
select name, minv,maxv from CTE1
___________________________________________________________________________________
____
class Solution(object):
def mergeAlternately(self, word1, word2):
"""
:type word1: str
:type word2: str
:rtype: str
"""
result = []
i = 0
while i < len(word1) or i < len(word2):
if i < len(word1):
result.append(word1[i])
if i < len(word2):
result.append(word2[i])
i += 1
return ''.join(result)
Select all employee detail with First name "Vikas","Ashish", and "Nikhil".
Select first name from "EmployeeDetail" table after removing white spaces from
right side
#Display first name and Gender as M/F.(if male then M, if Female then F)
#Get employee details from "EmployeeDetail" table whose Salary greater than
600000
select max(salary) from emp where salary<(select max(salary) from emp where salary)
#Write the query to get the department and department wise total(sum) salary
from "EmployeeDetail" table
####Write down the query to fetch Project name assign to more than one Employee
select Projectname, count(*) Noempp from project
group by Projectname
having count(*)>1
###Get employee name, project name order by firstname from "EmployeeDetail" and
"ProjectDetail" for those employee which have assigned project already.
Data Validations
- Metadata validation
- Data integrity check
- Rocord count check
- Data transformation check
- Data validation check
- Initial load and incremental loads
List dept no., Dept name for all the departments in which there are no employees in
the department.
select * from dept where deptno not in (select deptno from emp);
alternate solution: select * from dept a where not exists (select * from emp b
where a.deptno = b.deptno);
altertnate solution: select empno,ename,b.deptno,dname from emp a, dept b where
a.deptno(+) = b.deptno and empno is null;
Suppose there is annual salary information provided by emp table. How to fetch
monthly salary of each and every employee?select ename,sal/12 as monthlysal from
emp;
Select all record from emp table where deptno =10 or 40.select * from emp where
deptno=30 or deptno=10;
Select all record from emp table where deptno=30 and sal>1500.select * from emp
where deptno=30 and sal>1500;
Select all record from emp where job not in SALESMAN or CLERK.select * from emp
where job not in ('SALESMAN','CLERK');
Select all records where ename starts with ‘S’ and its lenth is 6 char.select *
from emp where ename like'S____';
Select all records where ename may be any no of character but it should end with
‘R’.select * from emp where ename like'%R';
Count MGR and their salary in emp table.select count(MGR),count(sal) from emp;
Select any salary <3000 from emp table. select * from emp where sal> any(select sal
from emp where sal<3000);
Select all salary <3000 from emp table. select * from emp where sal> all(select sal
from emp where sal<3000);
Select all the employee group by deptno and sal in descending order.select
ename,deptno,sal from emp order by deptno,sal desc;
How can I create an empty table emp1 with same structure as emp?Create table emp1
as select * from emp where 1=2;
Select all records where dept no of both emp and dept table matches.
select * from emp where exists(select * from dept where emp.deptno=dept.deptno)
If there are two tables emp1 and emp2, and both have common record. How can I fetch
all the recods but common records only once?