Order Of Execution of the SQL query

0 votes

I'm not sure what sequence this query should be executed in; could you help explain? When the join is applied, the function is executed, a new column with the Case is created, and the serial number is added, I'm perplexed. Please clarify the sequence in which all of this will be carried out.

select Row_number() OVER(ORDER BY (SELECT 1))  AS 'Serial No', 
    E.FullName,[dbo].[GetBookingRole](EC.CustomerId,E.BookingRole) as Role,  
    (select top 1 convert(varchar(10),eventDay,108)from [3rdi_EventDays] where EventNo=16) as EventDay,
    (CASE [dbo].[GetBookingRole](EC.CustomerId,E.BookingRole)  
            WHEN    '90 Day Client' THEN 'CC'
            WHEN    'Association Client'  THEN  'CC'
            WHEN    'Autism Whisperer'    THEN  'CC'
            WHEN    'CampII'             THEN   'AA' 
            WHEN    'Captain'              THEN 'AA' 
            WHEN    'Chiropractic Assistant' THEN 'AA'
            WHEN    'Coaches'               THEN 'AA'
            END) as Category from [3rdi_EventParticipants] as E  
    inner join [3rdi_EventSignup] as EC on E.SignUpId = EC.SignUpId  
    where E.EventId = 16
    and userid in (  
    select distinct customerid from customerroles  
    --where roleid not in(6,6,60,68) and roleid not in(1,2))  
    where roleid not in(20, 21, 22, 23) and roleid not in(1,2))
Feb 25, 2022 in Database by Vaani
• 7,020 points
674 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Database

0 votes
2 answers

Write a SQL query to find the names of employees that begin with ‘S’

Select ename From emp Where ename like"s%"; READ MORE

answered Oct 7, 2021 in Database by anonymous
25,504 views
0 votes
1 answer

What is the SQL query to get the third highest salary of an employee from employee_table

You can try out something like this: SELECT ...READ MORE

answered Sep 27, 2018 in Database by Sahiti
• 6,370 points
11,609 views
0 votes
1 answer

Ordering by the order of values in a SQL IN() clause

Use MySQL's FIELD() function: SELECT name, description, ... FROM ... WHERE id ...READ MORE

answered Feb 4, 2022 in Database by Neha
• 9,060 points
4,478 views
0 votes
0 answers

What is the purpose of Order By 1 in SQL select statement?

I discovered numerous views with an order ...READ MORE

Aug 19, 2022 in Database by Kithuzzz
• 38,010 points
521 views
0 votes
1 answer

What are the advantages of SQL?

Simple SQL queries can be used to ...READ MORE

answered Nov 8, 2018 in Database by DataKing99
• 8,240 points
5,815 views
0 votes
1 answer

What are the different types of join in SQL?

Hi Suraj, You have a doubt regarding inner join ...READ MORE

answered May 28, 2019 in Database by sampriti
• 1,120 points
1,116 views
0 votes
1 answer

Calculate Time Intersection to Correlate Sequences of Independent Events

I think this solution requires a CROSS JOIN implementation. ...READ MORE

answered Oct 26, 2018 in Power BI by Upasana
• 8,620 points
586 views
0 votes
1 answer

How do I UPDATE from a SELECT in SQL Server?

MERGE INTO YourTable T USING ...READ MORE

answered Feb 3, 2022 in Database by Vaani
• 7,020 points
604 views
0 votes
0 answers

How do I UPDATE from a SELECT in SQL Server?

INSERT INTO Table (col1, col2, col3) SELECT col1, ...READ MORE

Feb 4, 2022 in Database by Vaani
• 7,020 points
331 views
0 votes
1 answer

What is a stored procedure?

A stored procedure is a set of ...READ MORE

answered Feb 4, 2022 in Database by Neha
• 9,060 points
813 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP