Cloud Challengers
Cloud Challengers
  • 51
  • 122 903
Infosys SQL Interview Question
SQL questions recently asked in Infosys interview. We need to find origin and final destination details.
To find out the expected output, I use joins.
--Create table syntax
CREATE TABLE Flights (cust_id INT, flight_id VARCHAR(10), origin VARCHAR(50), destination VARCHAR(50));
-- Insert data into the table
INSERT INTO Flights (cust_id, flight_id, origin, destination)
VALUES (1, 'SG1234', 'Delhi', 'Hyderabad'), (1, 'SG3476', 'Kochi', 'Mangalore'), (1, '69876', 'Hyderabad', 'Kochi'), (2, '68749', 'Mumbai', 'Varanasi'), (2, 'SG5723', 'Varanasi', 'Delhi');
For more SQL interview questions. Check out our playlist.
ua-cam.com/play/PLxHEfsUVhEwMqw-nDG2zd3mpXpvY1v9xX.html&si=wT1GK4FFWAsLRxpX
Contact us:
info@cloudchallengers.com
Follow us on
Instagram : cloudchallengers
Facebook : cloudchallengers
LinkedIn : linkedin.com/company/cloudchallengers
Переглядів: 3 189

Відео

Genpact Python Interview Questions
Переглядів 1,5 тис.14 днів тому
Python questions recently asked in Genpact interview. In this video you will learn how to make use of for loop. Contact us: info@cloudchallengers.com Follow us on Instagram : cloudchallengers Facebook : cloudchallengers LinkedIn : linkedin.com/company/cloudchallengers
KPMG SQL Interview Question - Using ROW_NUMMBER( ) & CASE Statement
Переглядів 2,2 тис.21 день тому
SQL questions recently asked in KPMG interview. We need to find running total on the transactions table. To find out running total we use functions like ROW_NUMBER() and CASE statement. Create table syntax CREATE TABLE transactions_1308 (transaction_id BIGINT, type VARCHAR(50), amount INT,transaction_date DATE) Insert data into the table INSERT INTO transactions_1308 VALUES (53151, 'deposit', 1...
NTT Data Pyspark Interview Question
Переглядів 62121 день тому
Pyspark Interview questions recently asked in NTT Data interview. We need to add prefix to all the columns in the given dataframe. Lets see how we can achieve this by using Pyspark. Mentioning the dataframe details here data = [(101, 'IT', 1000), (102, 'HR', 900) columns = ["empid", "dept", "salary"] df = spark.createDataFrame(data, columns)] For more Azure Data Bricks interview questions. Chec...
Hero Motocorp SQL Interview Questions using REPLICATE(), RIGHT() and CONCAT() Functions
Переглядів 3,3 тис.Місяць тому
SQL questions recently asked in Motocorp interview. 1. We need to mask first 12 digits of card number. 2. Need to select employee names with same salary. Create table syntax CREATE TABLE cards (card_number BIGINT) INSERT INTO cards VALUES (1234567812345678),(2345678923456789),(3456789034567890) CREATE TABLE Employee (employee_id INT,ename VARCHAR(50),salary INT) INSERT INTO Employee VALUES (3, ...
GrayMatter Pyspark Interview Question - Get null count of all columns
Переглядів 710Місяць тому
Pyspark Interview questions recently asked in GrayMatter interview. We need to Get null count of all columns in dataframe. Lets see how we can achieve this by using Pyspark. Mentioning the dataframe details here data = [(1, None, 'ab'), (2, 10, None), (None, None, 'cd')] columns = ['col1', 'col2', 'col3'] df = spark.createDataFrame(data, columns) For more Azure Data Bricks interview questions. ...
WIPRO SQL Interview Question - FIRST_VALUE( ) Function
Переглядів 12 тис.Місяць тому
One of the SQL questions recently asked in WIPRO interview. We need to Find department wise minimum salary empname and maximum salary empname . To solve this, we will write a query by using FIRST_VALUE() windows function for first approach and Rownumber() function for second approach. Create table syntax CREATE TABLE emps_tbl (emp_name VARCHAR(50), dept_id INT, salary INT); INSERT INTO emps_tbl...
Persistent Systems SQL Interview Question using LEAST(), GREATEST() and ROW_NUMBER() Functions
Переглядів 2,4 тис.Місяць тому
One of the SQL questions recently asked in Persistent Systems interview. We need to Find unique combination of records in output. To solve this, we will write a query by using least, greatest and Rownumber() functions. Create table syntax CREATE TABLE routes (Origin VARCHAR(50), Destination VARCHAR(50)); INSERT INTO routes VALUES ('Bangalore', 'Chennai'), ('Chennai', 'Bangalore'), ('Pune', 'Che...
GlobalLogic Pyspark Interview Questions
Переглядів 669Місяць тому
Pyspark Interview questions recently asked in GlobalLogic interview. 1. We need to Convert every first letter of word in name to capital letter. 2. Get rows from df1 that are not present in df2 Lets see how we can achieve this by using Pyspark. Mentioning the dataframe details here # Sample data data = [("virat kohli",), ("p v sindhu",)] # Create DataFrame columns = ["name"] df = spark.createDa...
Happiest Minds SQL and Pyspark Interview Question
Переглядів 1,1 тис.Місяць тому
One of the Interview question recently asked in Happiest Minds interview. We need to Get only integer values in the output. Lets see how we can solve this by using try_cast() in SQL and Pyspark. Create table and insert data CREATE TABLE emp_new (employee_id VARCHAR(50) ) INSERT INTO emp_new (employee_id) VALUES ('72657'),('1234'),('Tom'),('8792'),('Sam'),('19998'),('Philip') For more Azure Data...
Affine Technologies SQL Interview question - Find 2nd Wednesday of current month.
Переглядів 1,4 тис.Місяць тому
One of the SQL questions recently asked in Affine Technologies interview. We need to Find 2nd Wednesday of current month. To solve this, we will write a query by using Recursive CTE and Rownumber() function. For more SQL interview questions. Check out our playlist. ua-cam.com/play/PLxHEfsUVhEwMqw-nDG2zd3mpXpvY1v9xX.html&si=wT1GK4FFWAsLRxpX Contact us: info@cloudchallengers.com Follow us on Inst...
TCS SQL Interview Question - Find product wise total amount, including products with no sales
Переглядів 4,2 тис.2 місяці тому
One of the SQL questions recently asked in TCS interview. Given us products and transactions table, We need to Find product wise total amount, including products with no sales. Let us create table and insert data create table products (pid int, pname varchar(50), price int) insert into products values (1, 'A', 1000),(2, 'B', 400),(3, 'C', 500); create table transcations (pid int, sold_date DATE...
PwC SQL Interview Question - Find the percentage of Genders
Переглядів 3,6 тис.2 місяці тому
One of the SQL questions recently asked in PwC interview. Given us Employee table, We need to Find the percentage of Genders. In order to solve this questions, we used Case Statement and GroupBy count. Let us create table and insert data CREATE TABLE employees_tbl (eid INT, ename VARCHAR(50), gender VARCHAR(10)) INSERT INTO employees_tbl VALUES (1, 'John Doe', 'Male'),(2, 'Jane Smith', 'Female'...
Brillio Pyspark Interview Question - Find non repeated employee details
Переглядів 6852 місяці тому
One of the Pyspark Interview question recently asked in Brillio interview. We need to Get non repeated employee details. Lets see how we can achieve this by using GroupBy count and Windows count. Mentioning the dataframe details here # Sample data data = [ (100, 'IT', 100, '2024-05-12'), (200, 'IT', 100, '2024-06-12'), (100, 'FIN', 400, '2024-07-12'), (300, 'FIN', 500, '2024-07-12'), (300, 'FIN...
Bayer SQL Interview Question-Dept wise 2nd Highest Salary using DENSE_RANK() and Correlated Subquery
Переглядів 1,8 тис.2 місяці тому
One of the SQL questions recently asked in Bayer interview. Given us Employee and Department tables, We need to Find Department wise 2nd Highest Salary. In order to solve this questions, we used SQL JOINS and DENSE_RANK() Function. You will understand how DENSE_RANK() and Correlated Subquery works. Let us create tables and insert data CREATE TABLE department (deptid INT, deptname VARCHAR(50)) I...
R Systems SQL Interview Question - Find the Currency Exchange rate at beginning and ending of month
Переглядів 1,6 тис.2 місяці тому
R Systems SQL Interview Question - Find the Currency Exchange rate at beginning and ending of month
Capgemini SQL Interview Question - Find aggregated cost of product
Переглядів 1,8 тис.3 місяці тому
Capgemini SQL Interview Question - Find aggregated cost of product
JLL Pyspark Interview Question - Get Top3 pickup locations
Переглядів 6503 місяці тому
JLL Pyspark Interview Question - Get Top3 pickup locations
JLL SQL Interview Question - Get Employee Name whose salary is greater than Manager Salary
Переглядів 1,8 тис.3 місяці тому
JLL SQL Interview Question - Get Employee Name whose salary is greater than Manager Salary
Ecolab SQL Interview Question - SUBSTRING() and CHARINDEX() Functions
Переглядів 2,8 тис.3 місяці тому
Ecolab SQL Interview Question - SUBSTRING() and CHARINDEX() Functions
Infosys/InxiteOut Data Bricks Interview Question - Pass parameters from ADF to Databricks Notebook.
Переглядів 6123 місяці тому
Infosys/InxiteOut Data Bricks Interview Question - Pass parameters from ADF to Databricks Notebook.
Mphasis SQL Interview question - UPDATE scores column values with department wise maximum score
Переглядів 2,3 тис.3 місяці тому
Mphasis SQL Interview question - UPDATE scores column values with department wise maximum score
LTIMindtree ADF Interview Question - Run multiple ADF pipelines parallelly
Переглядів 6483 місяці тому
LTIMindtree ADF Interview Question - Run multiple ADF pipelines parallelly
IKRUX SQL Interview Question - SQL JOINS, GROUP BY, STRING_AGG() Function
Переглядів 1,7 тис.3 місяці тому
IKRUX SQL Interview Question - SQL JOINS, GROUP BY, STRING_AGG() Function
SONY Python Interview Questions
Переглядів 6913 місяці тому
SONY Python Interview Questions
Data Semantics SQL Interview Question - REPLACE and LEN Functions in SQL
Переглядів 1,6 тис.3 місяці тому
Data Semantics SQL Interview Question - REPLACE and LEN Functions in SQL
Marlabs ADF Interview question - Send Email notifications using Alerts and Metrics in ADF
Переглядів 3303 місяці тому
Marlabs ADF Interview question - Send Email notifications using Alerts and Metrics in ADF
Capgemini SQL Interview Question - Find the percentage variance of sales from previous day
Переглядів 8 тис.3 місяці тому
Capgemini SQL Interview Question - Find the percentage variance of sales from previous day
Ascendion SQL Interview Question - Find Largest value
Переглядів 2,2 тис.3 місяці тому
Ascendion SQL Interview Question - Find Largest value
SQL Interview Question - Find Total Weekend working hours
Переглядів 2,7 тис.4 місяці тому
SQL Interview Question - Find Total Weekend working hours

КОМЕНТАРІ

  • @seshulatha
    @seshulatha День тому

    Cross apply mean cross join??

  • @seshulatha
    @seshulatha День тому

    I didn’t get the defining the months part …. Plz would u please explain why should we do that..

  • @ranjeetdeshmukh2278
    @ranjeetdeshmukh2278 День тому

    How much salary will a fresher get for SQL?

  • @hairavyadav6579
    @hairavyadav6579 2 дні тому

    Hi Sir , Please let me know this will work or not with cte as(select *, case when type="deposit" then amount else -(amount) end as total, row_number() over(partition by transaction_date order by (select null)) rn from trans) select transaction_id,type,amount,transaction_date,sum(total) over(order by transaction_date ,rn) as running_total from cte;

  • @manishsathe8371
    @manishsathe8371 2 дні тому

    Logic is important, If you have logic then you can write query Well Done !

  • @user-wg4bh3rv5i
    @user-wg4bh3rv5i 2 дні тому

    Please provide more scenario based interview questions

  • @sravankumar1767
    @sravankumar1767 2 дні тому

    Superb explanation 👌 👏 👍

  • @yashkumarmundada2203
    @yashkumarmundada2203 3 дні тому

    Another approach - select c as cust_id , max(origin) as origin, max(final_destination) as final_destination from ( select cust_id as c, case when origin not in (select destination from flights where cust_id = c) then origin end origin, case when destination not in (select origin from flights where cust_id = c) then destination end final_destination from flights) t group by cust_id

  • @Ujjwalmishra-t1w
    @Ujjwalmishra-t1w 3 дні тому

    Sir u are a nice person

  • @akash.i7391
    @akash.i7391 3 дні тому

    In the Oracle Database.. We don't have that function ( least () , greatest() , what should I do now..?

    • @CloudChallengers
      @CloudChallengers 2 дні тому

      least (), greatest() functions should work in oracle. Please check your query

  • @user-jj4bf4xy8o
    @user-jj4bf4xy8o 4 дні тому

    Oracle with rs as ( SELECT dt,sales,((sales/lag(sales,1) over (order by dt))-1)*100 sale_per from salesvar_tbl ) select dt,sales,sale_per from rs where sale_per>0 or sale_per is null;

  • @hairavyadav6579
    @hairavyadav6579 4 дні тому

    My approach select cust_id, max(case when (cust_id,origin) not in (select cust_id,destination from flights group by cust_id,destination) then origin end) as origin , max(case when (cust_id,destination) not in (select cust_id,origin from flights group by cust_id,origin) then destination end) as destination from flights group by cust_id;

  • @Jhanavi.Sunilkongadi
    @Jhanavi.Sunilkongadi 4 дні тому

    SELECT ORIGIN,DESTINATION FROM (SELECT*,ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS RNUM FROM ROUTE) A WHERE RNUM NOT IN (2);

  • @chandanpatra1053
    @chandanpatra1053 4 дні тому

    Thanks for bringing a valuable question. Actually this question is a leetcode DSA question which was solved in ankitbansal youtube channel before 6 months. Link: ua-cam.com/video/XssFpKFSNFw/v-deo.html Since you have used only 1 method to solve i.e. using self joins. But he explained another method also along with self joins method using "union all", "cte", "case stat" and "windows function". I like the second method. Logic used to solve using 2nd method: - First uinion all the start & end locations - then use count(*) of those start & end locations - then only filter where count=1 using max/min & case statement to ignore null values. keep it up. Bring such good questions. already liked the video.

  • @snehsparsh7954
    @snehsparsh7954 4 дні тому

    -- Solution using approach unbounded preceding WITH brand_vw AS ( SELECT *, LAST_VALUE(category IGNORE NULLS) OVER (ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS new_category FROM brands ) SELECT new_category, brand_name FROM brand_vw ORDER BY id;

  • @snehsparsh7954
    @snehsparsh7954 4 дні тому

    WITH cineamas_seat_stats AS ( SELECT *, LAG(free,1,0) OVER(ORDER BY seat_id ASC) AS Prev_Seat_Availability, LEAD(free,1,0) OVER(ORDER BY seat_id ASC) AS Next_Seat_Availability, FROM practiceDB1.cinema_tbl ORDER BY 1 ) SELECT seat_id, FROM cineamas_seat_stats WHERE free = 1 AND (prev_Seat_Availability = 1 OR Next_Seat_Availability = 1) ;

  • @jrtrishi2368
    @jrtrishi2368 4 дні тому

    bro how to apply for sql job roles? is it possible for 2022 batch as a fresher?

    • @CloudChallengers
      @CloudChallengers 4 дні тому

      @jrtrishi2368, try applying in Naukri and LinkedIn. Try to get referrals from LinkedIn.

  • @Chathur732
    @Chathur732 4 дні тому

    SIMPLE SOLUTION: select cust_id, min(case when (cust_id,origin) not in (select cust_id,destination from flights) then origin end) as origin, max(case when (cust_id,destination) not in (select cust_id,origin from flights) then destination end) as final_destination from flights group by cust_id order by cust_id

    • @MubarakAli-qs9qq
      @MubarakAli-qs9qq 9 годин тому

      Bhai aap bhot. Hoshiyar ho

    • @Chathur732
      @Chathur732 8 годин тому

      ​@@MubarakAli-qs9qq happy that you found it useful. :)

  • @adityavamsi12
    @adityavamsi12 4 дні тому

    Amazing...please bring complex questions like this❤

  • @anuragsarkar7710
    @anuragsarkar7710 4 дні тому

    If I want to make it where the output will be.. customerid, origin, destination, via via column will contains the values of the cities other than source and destination. Like for customerid = 2, via will be Pune For customerid = 1, via = Hyderabad, Kochi

  • @anirbanbiswas7624
    @anirbanbiswas7624 5 днів тому

    with cte as(select *,dayname(date(id)) as day_name, case when lead(dayname(id)) over(partition by empid,month(id) order by date(id)) in ('saturday','sunday') then lead(id) over(partition by empid,month(id) order by date(id)) end as next_working_time from emp_tbl) select empid,sum(timestampdiff(hour,id,next_working_time)) from cte group by empid

  • @hairavyadav6579
    @hairavyadav6579 5 днів тому

    Great question ::: My approach please let me know this will work or not with cte as (select *,case when col2> col3 then col2 else col3 end as max from tbl_maxval) select col1,max as maxval from cte;

  • @snehsparsh7954
    @snehsparsh7954 5 днів тому

    My approach using UNION - -- Approach 1: Using union SELECT * FROM happiness_tbl WHERE country = 'India' UNION ALL SELECT * FROM happiness_tbl WHERE country = 'Srilanka' UNION ALL SELECT * FROM happiness_tbl WHERE country NOT IN ('India', 'Srilanka') ORDER BY CASE WHEN country = 'India' THEN 1 WHEN country = 'Srilanka' THEN 2 ELSE 3 END;

  • @Ujjwalmishra-t1w
    @Ujjwalmishra-t1w 5 днів тому

    Nice

  • @hairavyadav6579
    @hairavyadav6579 6 днів тому

    My solution alter table studnts_tbl add column grade varchar(50); update studnts_tbl set grade = case when marks >=80 then "excellent" when marks >=60 and marks<80 then "v good" when marks >=35 and marks <60 then "good" else "poor" end;

  • @Jhanavi.Sunilkongadi
    @Jhanavi.Sunilkongadi 6 днів тому

    SELECT * FROM TABLEA UNION ALL SELECT * FROM TABLEB WHERE EMPID=3; Another approach ! Thank you! your videos helping me to learn SQL better !

  • @hairavyadav6579
    @hairavyadav6579 7 днів тому

    Interesting question,,, but solution is not dynamic if table is long then it difficult to us.. My approach dynamic solution ...... with cte as(select *,case when ranking = (select max(ranking) from happiness_tbl) then 2 when ranking = (select max(ranking) from happiness_tbl where ranking != (select max(ranking) from happiness_tbl)) then 1 else 3 end as derivedrank from happiness_tbl) select * from cte order by derivedrank; Please let me know this will work or not .....sir ji

    • @CloudChallengers
      @CloudChallengers 4 дні тому

      @hairavyadav6579, Thanks for your comments. This question is not about max rankings. I just taken test dataset with few records only, we may have some other countries available after India. In that case, max will the highest ranking country.

    • @hairavyadav6579
      @hairavyadav6579 3 дні тому

      @@CloudChallengers Thanks for updating me

  • @hairavyadav6579
    @hairavyadav6579 7 днів тому

    One of the best question

  • @hairavyadav6579
    @hairavyadav6579 7 днів тому

    Love this question i am solving in mysql i face may difficulty but i enjoy mysql solution with recursive num as(select date_format(curdate(),"%Y-%m-01") as date union all select date_add(date, interval 01 day) from num where month(date_add(date, interval 01 day)) = month(curdate())), cte as(select *,date_format(date,"%W")as weekday from num where date_format(date,"%W") = "Wednesday") select date as 2nd_wednesday from (select *, row_number() over(order by date) rnk from cte) sal where rnk =2;

  • @SURESHK-hq3wf
    @SURESHK-hq3wf 7 днів тому

    empID empname salary Deptid Deptname rn 1 kalyan 39000 208 Finance 1 2 raju 35000 208 Finance 2 3 Raju 4500 206 HR 1 4 ramu 40000 206 HR 2 5 kishor 50000 207 IT 1 6 anitha 50000 207 IT 1 7 nikhiltha 42000 207 IT 3 can you give code fo the above table. i have tried using rank function but it is not coming

  • @hairavyadav6579
    @hairavyadav6579 8 днів тому

    my answer with cte as (select *,lag(sales) over(order by dt) pv from sales1) select dt,sales,`%v` from (select*,ifnull(round((sales-pv)*100/pv,0),0) as `%v` from cte) sal where `%v` >=0;

  • @akash.i7391
    @akash.i7391 8 днів тому

    Bro.. I am using oracle database... Is there any change in oracle ?

    • @CloudChallengers
      @CloudChallengers 4 дні тому

      @akash.i7391, It should work in oracle as well.

    • @akash.i7391
      @akash.i7391 3 дні тому

      @@CloudChallengers but in Oracle first values function includes some statement like unbounded preceding something) ..if i was not using this key word ,it through error..I am using Oracle 11 g version

  • @hairavyadav6579
    @hairavyadav6579 8 днів тому

    Great question , i solved and post daily sql question on linkdin and also tag you but you can't like or any thing, i think you are not active on linkdin

    • @CloudChallengers
      @CloudChallengers 4 дні тому

      @hairavyadav6579, Due to some personal commitments I'm not much active on LinkedIn these days. I will start responding soon.

  • @hairavyadav6579
    @hairavyadav6579 9 днів тому

    with cte as(select *,lag(ytd_sales,1,0) over(order by monthnum) amt from sales) select month,ytd_sales, (ytd_sales-amt) periodic_sales from cte;

  • @hairavyadav6579
    @hairavyadav6579 9 днів тому

    with cte as ( select count(gender) ra from employee_tbl), hai as(select sum(case when gender = "male" then 1 end) as mal, sum(case when gender = "female" then 1 end) as fem from employee_tbl) select round((mal*100)/ra,0) as male_per, round((fem*100)/ra,0) as female_per from cte,hai; My approach please reply i am right or not sir

  • @manishsathe8371
    @manishsathe8371 9 днів тому

    With CTE As ( Select *, case when Transaction_Type='deposit' then Transaction_Amount*1 when Transaction_Type='withdrwal' then Transaction_Amount*-1 end as Amount_For_RT from [Transaction Details]) Select * , SUM(CTE.Amount_For_RT)Over(Order by (Select Null) rows between unbounded preceding and current row) as RT from CTE

  • @hairavyadav6579
    @hairavyadav6579 9 днів тому

    select e2.ename as employee_name from employees_tbl e1 join employees_tbl e2 on e1.empid =e2.managerid where e2.salary>e1.salary;

  • @hairavyadav6579
    @hairavyadav6579 10 днів тому

    select substring_index(email,"@",-1) as domain from customer_tbl; select substr(email,locate("@",email)+1) as domain from customer_tbl; select right(email,(length(email) - locate("@",email))) as domain from customer_tbl; My approach

  • @hairavyadav6579
    @hairavyadav6579 10 днів тому

    select max(id) as max_id from (select id from employees group by id having count(*) = 1) sal;

  • @gkapadi9831
    @gkapadi9831 12 днів тому

    In oracle sql - Select substr(email,instr(email,'@')+1) as domain from customer_tbl;

  • @hairavyadav6579
    @hairavyadav6579 13 днів тому

    Sir script de dya kro practice krne ke lye

    • @CloudChallengers
      @CloudChallengers 10 днів тому

      you can get create table syntax in description

  • @hairavyadav6579
    @hairavyadav6579 13 днів тому

    with cte as ( select *, first_value(salary) over(partition by dept_id order by salary) min , first_value(salary) over(partition by dept_id order by salary desc) max from emps) select dept_id,max(case when salary = min then emp_name end) as min_salary_emp_name, max(case when salary = max then emp_name end) as max_salary_emp_name from cte group by 1;

  • @hairavyadav6579
    @hairavyadav6579 13 днів тому

    my solution please let me know this is fine or not with cte as( select *, dense_rank() over(partition by dept_id order by salary) min ,dense_rank() over(partition by dept_id order by salary desc) max from emps) select dept_id,max(case when min = 1 then emp_name end) as min_salary, max(case when max=1 then emp_name end) as max_salary from cte group by 1;

  • @harshkhannashorts
    @harshkhannashorts 14 днів тому

    Using full join

  • @harshkhannashorts
    @harshkhannashorts 14 днів тому

    By using full join this case will be resolved.

  • @rishabhralli9151
    @rishabhralli9151 15 днів тому

    with cte as( select *, case when type='deposit' then 1*amount else -1*amount end as new_amount from transactions_1308) select transaction_id,type,amount,transaction_date, sum(new_amount) over(order by transaction_date rows between unbounded preceding and current row) as running_sum from cte;

  • @lakshmanlee3579
    @lakshmanlee3579 16 днів тому

    Code: with cte as (select *, row_number() over (order by seat_id) rn from cinema_tbl where free = 1), cte2 as ( select seat_id,free,(seat_id - rn ) num from cte), final as ( select seat_id, count(num) over (partition by num) cnt from cte2) select seat_id from final where cnt > 1

  • @lakshmanlee3579
    @lakshmanlee3579 16 днів тому

    Code : with cte as (select *,count(id) over (partition by id order by id) rn from employees) select max(id) id from cte where rn = 1

  • @pravinshinde1891
    @pravinshinde1891 16 днів тому

    select lpad('*',12,'*')||''||rpad(CARD_NUMBER,4) as card_number from cards

  • @himanshushorts7143
    @himanshushorts7143 16 днів тому

    l = ['A2','B3','C10'] l1 = [] for i in l: s = '' n = '' for j in i: if j.isalpha(): s += j else: n += j l1.append(s*int(n)) print(l1) ---------------------------------------------------------------------------- l1 = [1,3] l2 = [1,3,4] res = [] def fun(lst1,lst2): for i in lst1: if i not in lst2: res.append(i) if len(l1)>len(l2): fun(l1,l2) else: fun(l2,l1) print(res)