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 in Database by Vaani
• 5,240 points
44 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
12,467 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,360 points
7,072 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 in Database by Neha
• 6,260 points
216 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
4,787 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
637 views
+1 vote
0 answers

What are the advantages of SQL?

Dec 28, 2019 in Database by Yuth
• 130 points

closed Dec 30, 2019 by Kalgi 601 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
286 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 in Database by Vaani
• 5,240 points
39 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 in Database by Vaani
• 5,240 points
14 views
0 votes
1 answer

What is a stored procedure?

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

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