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,070 points
847 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
27,102 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
12,623 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,020 points
5,278 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,000 points
679 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,250 points
5,971 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,298 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
787 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,070 points
819 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,070 points
545 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,020 points
1,054 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