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

0 votes

I discovered numerous views with an order by 1 clause when browsing through some outdated code at work. What is the result of this?

Example:

Create view v_payment_summary AS
SELECT A.PAYMENT_DATE,
       (SELECT SUM(paymentamount)
          FROM payment B
         WHERE PAYMENT_DATE = B.PAYMENT_DATE
           and SOME CONDITION) AS SUM_X,
       (SELECT SUM(paymentamount)
          FROM payment B
         WHERE PAYMENT_DATE = B.PAYMENT_DATE
           and SOME OTHER CONDITION) AS SUM_Y    
FROM payment A    
ORDER BY 1;
Aug 19, 2022 in Database by Kithuzzz
• 38,010 points
517 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
0 answers

What is the purpose of using WHERE 1=1 in SQL statements?

Possible Duplicates: Why would a sql query have ...READ MORE

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

What is the ORDER BY statement in MySQL?

This statement is used to sort the ...READ MORE

answered Nov 23, 2018 in Database by Sahiti
• 6,370 points
464 views
0 votes
1 answer

What is the syntax of USE statement in MySQL?

The USE statement is used to mention ...READ MORE

answered Nov 27, 2018 in Database by Sahiti
• 6,370 points
584 views
0 votes
1 answer

What is the syntax of SELECT statement?

This statement is used to select data ...READ MORE

answered Nov 27, 2018 in Database by Sahiti
• 6,370 points
928 views
0 votes
1 answer

what is the syntax of OR statement in MySQL?

The OR operator displays those records which ...READ MORE

answered Dec 1, 2018 in Database by Sahiti
• 6,370 points
510 views
0 votes
1 answer

What is the definition of cardinality in SQL?

Cardinality is defined as the "number of ...READ MORE

answered Feb 15, 2022 in Database by Neha
• 9,060 points
1,569 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,474 views
0 votes
1 answer

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

We can use expressions as well in ...READ MORE

answered May 31, 2022 in Others by Sohail
• 3,040 points
276 views
0 votes
1 answer

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

Use MySQL FIND_IN_SET function: SELECT * ...READ MORE

answered Jun 6, 2022 in Others by nisha
• 2,210 points
482 views
0 votes
0 answers

SQL multiple column ordering

How can I sort in several ways ...READ MORE

Aug 29, 2022 in Database by Kithuzzz
• 38,010 points
294 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