- 105
- 50 424
Data Sculptor
India
Приєднався 1 січ 2024
🚀 Welcome to Data Sculptor , the go-to destination for mastering SQL, BI, and all things data-related! 📊
Are you gearing up for a career in data analytics, business intelligence, or database management? Look no further! Our channel is dedicated to providing you with in-depth insights, hands-on tutorials, and expert tips to ace your SQL and BI interviews.
Subscribe now and embark on a journey of continuous learning and growth in the vast realm of SQL, BI, and data management. Whether you're a seasoned professional or just starting, Data Sculptor is your compass in navigating the exciting and dynamic field of data!
🔗 Subscribe, hit the notification bell, and let's unlock the power of data together! 💡📈 #DataInsights #SQLInterview #BIInterview #DataAnalyticsMastery
Are you gearing up for a career in data analytics, business intelligence, or database management? Look no further! Our channel is dedicated to providing you with in-depth insights, hands-on tutorials, and expert tips to ace your SQL and BI interviews.
Subscribe now and embark on a journey of continuous learning and growth in the vast realm of SQL, BI, and data management. Whether you're a seasoned professional or just starting, Data Sculptor is your compass in navigating the exciting and dynamic field of data!
🔗 Subscribe, hit the notification bell, and let's unlock the power of data together! 💡📈 #DataInsights #SQLInterview #BIInterview #DataAnalyticsMastery
Відео
SQL INTERVIEW QUESTION | Advanced aggregation using GROUPINGSETS Function
Переглядів 177День тому
DML Script:datasculptor.blogspot.com/2024/07/advanced-sql-techniques-master-rollup.html Feedback: forms.gle/NQuCAy7p5a9wxW3LA The Data Sculptor UA-cam channel is a dedicated platform that explores the art and science of working with data. This channel caters to a diverse audience, including data enthusiasts, analysts, scientists, and anyone interested in harnessing the power of data for insight...
My office vlog | INTEL SRR campus | First Vlog
Переглядів 502 дні тому
SQL INTERVIEW QUESTION | Advanced aggregation using CUBE
Переглядів 5063 дні тому
DML Script: datasculptor.blogspot.com/2024/07/advanced-sql-techniques-master-rollup.html Feedback: forms.gle/NQuCAy7p5a9wxW3LA The Data Sculptor UA-cam channel is a dedicated platform that explores the art and science of working with data. This channel caters to a diverse audience, including data enthusiasts, analysts, scientists, and anyone interested in harnessing the power of data for insigh...
SQL INTERVIEW QUESTION | Advanced aggregation using ROLLUP
Переглядів 2175 днів тому
DML Script: datasculptor.blogspot.com/2024/07/advanced-sql-techniques-master-rollup.html Feedback: forms.gle/NQuCAy7p5a9wxW3LA The Data Sculptor UA-cam channel is a dedicated platform that explores the art and science of working with data. This channel caters to a diverse audience, including data enthusiasts, analysts, scientists, and anyone interested in harnessing the power of data for insigh...
SQL Interview question | Calculate 90th discrete percentile of each region | SQL
Переглядів 4196 днів тому
DML Script: datasculptor.blogspot.com/2024/07/sql-interview-question-calculate-90th.html Feedback: forms.gle/NQuCAy7p5a9wxW3LA The Data Sculptor UA-cam channel is a dedicated platform that explores the art and science of working with data. This channel caters to a diverse audience, including data enthusiasts, analysts, scientists, and anyone interested in harnessing the power of data for insigh...
INTEL INTERVIEW QUESTION | Showing Sales Amount by Order Date and Ship Date | DAX
Переглядів 4407 днів тому
Feedback: forms.gle/NQuCAy7p5a9wxW3LA The Data Sculptor UA-cam channel is a dedicated platform that explores the art and science of working with data. This channel caters to a diverse audience, including data enthusiasts, analysts, scientists, and anyone interested in harnessing the power of data for insightful and creative purposes. The channel covers a wide range of topics related to data man...
ORACLE INTERVIEW QUESTION | How to Assign Row Numbers Without ROW_NUMBER() Function
Переглядів 5398 днів тому
DML Script: datasculptor.blogspot.com/2024/07/oracle-interview-question-how-to-assign.html Feedback: forms.gle/NQuCAy7p5a9wxW3LA The Data Sculptor UA-cam channel is a dedicated platform that explores the art and science of working with data. This channel caters to a diverse audience, including data enthusiasts, analysts, scientists, and anyone interested in harnessing the power of data for insi...
SQL INTERVIEW QUESTION | Join 3 Tables & Filter Records in 2 Tables Only | SQL
Переглядів 5699 днів тому
DML Script: datasculptor.blogspot.com/2024/07/sql-interview-question-join-3-tables.html Feedback: forms.gle/NQuCAy7p5a9wxW3LA The Data Sculptor UA-cam channel is a dedicated platform that explores the art and science of working with data. This channel caters to a diverse audience, including data enthusiasts, analysts, scientists, and anyone interested in harnessing the power of data for insight...
Calculate 90th continuous percentile of each region | SQL | SQL Interview question
Переглядів 1,2 тис.11 днів тому
DML Script: datasculptor.blogspot.com/2024/07/ey-interview-question-calculate-90th.html Feedback: forms.gle/NQuCAy7p5a9wxW3LA The Data Sculptor UA-cam channel is a dedicated platform that explores the art and science of working with data. This channel caters to a diverse audience, including data enthusiasts, analysts, scientists, and anyone interested in harnessing the power of data for insight...
ACCENTURE INTERVIEW QUESTION | Rank products based on revenue | DAX
Переглядів 52811 днів тому
Feedback: forms.gle/NQuCAy7p5a9wxW3LA The Data Sculptor UA-cam channel is a dedicated platform that explores the art and science of working with data. This channel caters to a diverse audience, including data enthusiasts, analysts, scientists, and anyone interested in harnessing the power of data for insightful and creative purposes. The channel covers a wide range of topics related to data man...
EY INTERVIEW QUESTION | Categorize Salespersons by Sales Amount in SQL
Переглядів 1,1 тис.13 днів тому
DML Script: datasculptor.blogspot.com/2024/07/ey-interview-question-categorize.html Feedback: forms.gle/NQuCAy7p5a9wxW3LA The Data Sculptor UA-cam channel is a dedicated platform that explores the art and science of working with data. This channel caters to a diverse audience, including data enthusiasts, analysts, scientists, and anyone interested in harnessing the power of data for insightful ...
ADOBE SQL INTERVIEW QUESTION | Divide Employees into Buckets
Переглядів 1 тис.15 днів тому
DML Script: datasculptor.blogspot.com/2024/07/adobe-sql-interview-question-divide.html Feedback: forms.gle/NQuCAy7p5a9wxW3LA The Data Sculptor UA-cam channel is a dedicated platform that explores the art and science of working with data. This channel caters to a diverse audience, including data enthusiasts, analysts, scientists, and anyone interested in harnessing the power of data for insightf...
DAX Tutorial: SUM vs. SUMX - Get Your Calculations Right!
Переглядів 5716 днів тому
Feedback: forms.gle/NQuCAy7p5a9wxW3LA The Data Sculptor UA-cam channel is a dedicated platform that explores the art and science of working with data. This channel caters to a diverse audience, including data enthusiasts, analysts, scientists, and anyone interested in harnessing the power of data for insightful and creative purposes. The channel covers a wide range of topics related to data man...
AMAZON INTERVIEW QUESTION | Dynamic Score Calculation Without Updates | SQL INTERVIEW
Переглядів 54917 днів тому
DML Script: datasculptor.blogspot.com/2024/07/amazon-interview-question-dynamic-score.html Feedback: forms.gle/NQuCAy7p5a9wxW3LA The Data Sculptor UA-cam channel is a dedicated platform that explores the art and science of working with data. This channel caters to a diverse audience, including data enthusiasts, analysts, scientists, and anyone interested in harnessing the power of data for insi...
INTEL INTERVIEW QUESTION: Mastering SELECTCOLUMNS vs ADDCOLUMNS in DAX!
Переглядів 11218 днів тому
Feedback: forms.gle/NQuCAy7p5a9wxW3LA The Data Sculptor UA-cam channel is a dedicated platform that explores the art and science of working with data. This channel caters to a diverse audience, including data enthusiasts, analysts, scientists, and anyone interested in harnessing the power of data for insightful and creative purposes. The channel covers a wide range of topics related to data man...
but you not explain how you sort product like A,A,A,B,B,B,null,null,null my solution :- WITH cte AS ( SELECT product, region, SUM(sales) OVER(PARTITION BY product ORDER BY sales) AS r, ROW_NUMBER() OVER(PARTITION BY product ORDER BY sales DESC) AS rn FROM sales_rollup ) SELECT product, NULL AS region, r AS total_sales FROM cte WHERE rn = 1 UNION ALL SELECT NULL AS product, region, SUM(sales) AS total_sales FROM sales_rollup GROUP BY region UNION ALL SELECT NULL AS product, NULL AS region, SUM(sum_r) AS total_sales FROM ( SELECT region, SUM(sales) AS sum_r FROM sales_rollup GROUP BY region ) a UNION ALL SELECT product, region, SUM(sales) OVER(PARTITION BY product ORDER BY sales) AS total_sales FROM sales_rollup (i'm thinking to create temporary table then put all things in it after that sort )
This isn’t guaranteed to give you the same sort result every-time.
@@datasculptor2895 it's not about guarantee it's question how we get exact output including order by Here we are sharing knowledge and practice SQL so in interview may be interviewer ask i want exact same output (then what will you say ?)
That’s what my question is. How will your query return the output in the required sort order without using order by?
@@datasculptor2895 no, my query not return exact output ( not in order by) This things i mentioned in last line i can create one temporary table in which put this output then call temporary table output with order by (using case) This is my logic What's your?? I asked
Yes. Need not put in temporary table. You can use the order by directly in the query using case statement
Awesome! Content It requires a lot of hardwork for producing the content. Thankyou so much
Thank you. Please like share and subscribe
Interesting
Are you working as a data engineer in Intel? Are you from NIT/IIT ? If no then share your journey how you reached there. If yes then ignore.
Yes, I work as a data engineer in Intel. I am from VIT Vellore.
@@datasculptor2895 Hello, how much exp do you have as data engineer?
@@DE_Pranav 8+ years
Cant we do this by two inner join's it will give common between all three tables
No. Output should be present only in 2 tables
Hi, Please check the below scenario, as i'm getting different answer from my approach. For Ride = 10, it was requested_at 2020-03-04 and driver = 7 joined at 2020-03-08. Meaning only 3 drivers were available for ride_id 10 namely 10, 8, 5. Below is my approach. with RideCNT as ( Select CONVERT(varchar(6), R.requested_at, 112) as [YearMonth] , COUNT(R.ride_id) as RideReqCNT , COUNT(AR.ride_id) as RideAcceptCNT from Rides R LEFT JOIN AcceptedRides AR ON R.ride_id = AR.ride_id GROUP BY CONVERT(varchar(6), R.requested_at, 112) -- ORDER BY 1 ) , DriverCNT as ( Select CONVERT(nvarchar(6), R.requested_at, 112) As YearMonth , COUNT(DISTINCT R.ride_id) as RideReqCNT , COUNT(distinct driver_id) as DriverAvailCNT from Rides R LEFT JOIN Drivers D ON R.requested_at >= D.join_date GROUP BY CONVERT(nvarchar(6), requested_at, 112) ) Select A.YearMonth, A.RideReqCNT, B.DriverAvailCNT, A.RideAcceptCNT , CASE WHEN DriverAvailCNT = 0 THEN 0 ELSE RideAcceptCNT * 100.0 / DriverAvailCNT END AS working_percentage from RideCNT A INNER JOIN DriverCNT B ON A.YearMonth = B.YearMonth;
SELECT COALESCE( a.Id , b.Id) AS ID , CASE WHEN a.Name != b.Name THEN 'Source Mismatch' WHEN a.Name IS NULL THEN 'New In Target' WHEN b.Name IS NULL THEN 'New In Source' END as Comment FROM Source a FULL OUTER JOIN Target b ON a.Id = b.Id WHERE CASE WHEN a.Name != b.Name THEN 'Source Mismatch' WHEN a.Name IS NULL THEN 'New In Target' WHEN b.Name IS NULL THEN 'New In Source' END IS NOT NULL
Solve more questions on join and analytical functions
Hi, while using UNION ALL method to get the result in required format. I use below method. with cte as ( Select Product, Region, Sales AS TotalSales from Sales UNION ALL Select Product, NULL as Region , SUM(Sales) AS TotalSales From Sales GROUP BY Product UNION ALL Select Null as Product, NULL as Region , SUM(Sales) AS TotalSales From Sales ) Select * from cte Order by (CASE WHEN Product IS NULL THEN 'zz' ELSE Product END), (CASE WHEN Region IS NULL THEN 'zz' ELSE Region END);
Nice way to handle the ordering
Please bring more real-time power BI interview questions, like you do for SQL
Thanks for the new approach...
Hi, Below is my Solution. Please check your query result, as when i ran with 14 matches, there is some descrepency at winning_% and sequencing of teams For me, KKR > GT is coming. Declare @MN INT = 14; with teams as ( Select TeamA As[Team] from IPLResults UNION Select TeamB As[Team] from IPLResults ) , cte as ( Select TeamA as [Team], WinningTeam from IPLResults WHERE MatchN <= @MN UNION ALL Select TeamB, WinningTeam from IPLResults WHERE MatchN <= @MN ) , cte_final as ( Select T.Team , Count(CT.Team) as Played , SUM(CASE WHEN T.Team = CT.WinningTeam THEN 1 ELSE 0 END) AS Win , SUM(CASE WHEN T.Team <> CT.WinningTeam AND CT.WinningTeam <> 'NA' THEN 1 ELSE 0 END) AS Loss , SUM(CASE WHEN CT.WinningTeam = 'NA' THEN 1 ELSE 0 END) AS Draw from teams T LEFT JOIN cte CT ON T.Team = CT.Team Group by T.Team ) Select * , Win * 2 + Draw*1 as Points , Win *100.0 / Played as [Winning %] from cte_final Order by Points desc, [Winning %] DESC;
Really a brain storming question in powerBI . Thanks for bringing up such questions. Keep it up. 👍👍. It would be better if you provide those excel datasets gdrive link for our practice purpose .
simple approach----- with cte as (select a.id as id,a.valuea as vals from tablea2 as a join tableb as b on a.id=b.id and a.valuea=b.valueb), cte2 as(select b.id as id,b.valueb as vals from tableb as b join tablec as c on b.id=c.id and b.valueb=c.valuec) select c1.* from cte as c1 left join cte2 as c2 on c1.id=c2.id
Will this work if there is a common entry in all the 3 tables?
Glad to know
Hello bud, are we under the strict instructions to only 'JOIN' the tables or would it be ok to use 'Union'? Also, may I know where was this interview question asked? Thanks for the continuous content uploads, it helps a ton of folks!
I do not remember where this was asked, but the question was to achieve results using joins
Nice one brother keep up the great work 😊
Thanks. Please like and subscribe to my channel
Hi, Below is my approach. with cte as ( Select A.AttemptID, A.PlayerID, A.Score , MAX(CASE When B.AttemptID = 1 THEN A.Score - B.Score END) AS [Different First] , MAX(CASE When B.AttemptID = 3 THEN A.Score - B.Score END) AS [Different Last] , MAX(CASE WHEN A.AttemptID = 1 THEN 1 WHEN A.AttemptID = B.AttemptID + 1 AND A.Score >= B.Score THEN 1 ELSE 0 END ) AS [Is Previous Score Lower] from PlayerScores A INNER JOIN PlayerScores B ON A.PlayerID= B.PlayerID GROUP BY A.AttemptID, A.PlayerID, A.Score -- Order by A.PlayerID, A.AttemptID ) , cte_IMprv as ( Select PlayerID, CASE WHEN COUNT(AttemptID) = SUM([Is Previous Score Lower]) Then 1 ELSE 0 END AS [Is OverAll Improved] from cte group by PlayerID ) Select M.*, IM.[Is OverAll Improved] from cte M LEFT JOIN cte_IMprv IM ON M.PlayerID = IM.PlayerID Order by PlayerID, AttemptID
I use other window function SELECT *,DENSE_RANK()over(partition by department_id order by name) as rn FROM employees order by employee_id
Nice, but intention was to not use any window functions.
select i.a, i.b, sum(case when e.a = i.a and e.b = i.a then e.shipments + i.shipments end) as total_shipments from exp_imp e join exp_imp i on e.a = i.b and e.b = i.a and e.shipments < i.shipments group by i.a, i.b
Nice. Please subscribe to my channel 🙂
@@datasculptor2895 I did
is this a right approach using join? with cte as( select a.ID as id1,a.ValueA,b.ID as id2,b.ValueB,c.ID as id3,c.ValueC,case when a.ID=b.ID and a.ValueA=b.ValueB then 0 when b.ID=c.ID and b.ValueB=c.ValueC then 1 when c.ID=a.ID and c.ValueC=a.ValueA then 2 end flag, coalesce (case when a.ID=b.ID and b.ID=c.ID then 5 end,4) flag2 from TableA a FULL join TableB b on a.ID=b.ID AND A.ValueA=B.ValueB full join TableC c on b.ID=c.ID and b.ValueB=c.ValueC full join TableA aa on c.ID=aa.ID and c.ValueC=aa.ValueA )select id2,valueb from cte where flag2<>5 and flag in (0,1)
Yes. Please subscribe to my channel
@@datasculptor2895 already i subscribed it bro you are making excellent content 🙌🙌
@@devendrabarasker4987 Happy that you are liking my content. More interesting questions coming. Meanwhile you can let me know if you are looking out for any topics or questions.
@@datasculptor2895 power bi advanced level if possible...
@@devendrabarasker4987 Sure.. definitely.
Select salesrepid from (Select *,count(Salesrepid) as CNTfrom (Select * from (Select SalesrepId,row_Number() over (Partition by Salesrepid,SalesType) as RN from Orders)N where RN = 1) group by Salesrepid)N where CNT=1
Select *,Case When Amount=Min(Amount) over (Partition by Sales_person Order by Amount asc) Then "Lowest" When Amount=Max(Amount) over (Partition by Sales_person Order by Amount Desc) Then "Highest" When Amount=Avg(Amount) over (Partition by Sales_person Range between unbounded preceding and unbounded following) Then "Average" When Amount>Avg(Amount) over (Partition by Sales_person Range between unbounded preceding and unbounded following) Then "Above Average" When Amount<Avg(Amount) over (Partition by Sales_person Range between unbounded preceding and unbounded following) Then "Below Average" end as Category from sale order by Sales_person,amount;
Nice. Please subscribe to my channel
is this correct ? with cte as ( SELECT a.id , a.ValueA FROM TABLEA A JOIN TableB B ON A.ID=B.ID AND A.VALUEA=B.VALUEB union select b.ID , b.ValueB from tableb b join tablec c on b.id=c.ID and b.ValueB=c.ValueC union select a.ID, a.ValueA from TableA a join TableC c on a.ID=c.id and a.ValueA=c.ValueC) select * From cte;
Unfortunately this will not work. Row common in all the 3 tables will also appear in this
@@datasculptor2895 thanks
MYSQL Solution Select Name,Marks,Years,Pre_Year from (Select *, Case When Marks>=Pre_Year then 1 else 0 end as Flag from (Select *,Lag(Marks) over (Partition by Name Order by Years) as Pre_Year from Marks)N)N Where Flag=1;
Nice. Please subscribe to my channel
MySQL: WITH RankedData AS ( SELECT Region, revenue, ROW_NUMBER() OVER (PARTITION BY Region ORDER BY revenue) AS rn, COUNT(*) OVER (PARTITION BY Region) AS cnt FROM sales2 ), PercentilePositions AS ( SELECT Region, revenue, rn, cnt, 0.9 * (cnt - 1) + 1 AS percentile_pos FROM RankedData ), InterpolatedData AS ( SELECT Region, revenue AS lower_revenue, LEAD(revenue) OVER (PARTITION BY Region ORDER BY revenue) AS upper_revenue, rn, FLOOR(percentile_pos) AS lower_rn, CEIL(percentile_pos) AS upper_rn, percentile_pos FROM PercentilePositions ) SELECT *, CASE WHEN lower_rn = upper_rn THEN lower_revenue ELSE lower_revenue + (upper_revenue - lower_revenue) * (percentile_pos - lower_rn) END AS percentile_90 FROM InterpolatedData WHERE rn = lower_rn -- OR rn = upper_rn ORDER BY Region;
Is this giving the correct result?
Thanks for new function, I have learn new function today
Glad to hear that
sql intemediate advanced topics videos/resources cheyyandi bro
Sure.. definitely. Please subscribe to my channel.
SELECT *, CASE WHEN SALARY >=2000 AND SALARY <=3000 THEN 1 WHEN SALARY >=3500 AND SALARY <=4000 THEN 2 WHEN SALARY >=4500 AND SALARY <=5000 THEN 3 WHEN SALARY >=6000 AND SALARY <=7000 THEN 4 END SALARY_BUCKET FROM EMPLOYEES ORDER BY SALARY
Sorry, but this should not be done in this way. What if the salaries are changed in the dataset?
WITH CTE AS (SELECT * ,SUM(WEIGHT)OVER(ORDER BY LINEORDER ) AS CUMMSUM FROM ELEVATORORDER) SELECT NAME FROM CTE WHERE CUMMSUM<2000 ORDER BY LINEORDER DESC LIMIT 1
with cte as( select*, percent_rank() over(order by salary asc) as rn from employees ) select employee_id, salary, case when rn = 0 then '1' when rn = 0.125 then '1' when rn = 0.25 then '1' when rn = 0.375 then '2' when rn = 0.5 then '2' when rn = 0.625 then '3' when rn = 0.75 then '3' when rn = 0.875 then '4' else '4' end as Bucket from cte
Good question. Please keep posting such questions on DAX.
Thank you
SELECT Region, PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY Amount) OVER (PARTITION BY Region) AS median_amount FROM Sales;
Yes. Same is mentioned in the video.
SELECT Region, PERCENTILE_CONT(0.9) WITHIN GROUP (ORDER BY Amount) OVER (PARTITION BY Region) AS percentile_90 FROM table_name;
Yes. Same is mentioned in the video.
Well explained without predefined functions
Great sir.. You are intelligent.
Informative 🙂🙂👌👌👌make more such query based questions related to SQL (most important)
Thank you. Please subscribe to my channel 🙂
EE is associated with EE and shld not be return, only GG shld b return going by your own logic. Kindly review
EE is associated to echo and foxtarr, echo and foxtarr are not associated to any other codes so EE should also return. Hope this clears the confusion.
Here is my approach but i want to know if i don't use cte will there be any performance issue...? select top 2 DATENAME(dw,timestamp)dw,case when format(timestamp,'HH')<12 then 'morning' when format(timestamp,'HH')<17 then 'afternoon' else 'evening' end Time,count(orderid)order_cnt from orders group by DATENAME(dw,timestamp), case when format(timestamp,'HH')<12 then 'morning' when format(timestamp,'HH')<17 then 'afternoon' else 'evening' end order by count(orderid) desc
Nice. Using CTE might give you performance issue. If you are able to achieve without using cte and sub queries then it is great 😊
@@datasculptor2895 thank you so much for reply 🙌🙌
Brother please mention the question in description section or in blog site.
Ok.