Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

You must login to add post.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

mcqoptions.com

mcqoptions.com Logo mcqoptions.com Logo

mcqoptions.com Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 454271
Next
In Process
Ekbal Issac
Ekbal Issac
Asked: 3 years ago2022-11-07T23:51:17+05:30 2022-11-07T23:51:17+05:30In: General Awareness

Write the differences between order by and group by with example.

Write the differences between order by and group by with example.

Parabola
  • 0
  • 11
  • 0
  • 0
  • 0
    • Report
  • Share
    • Share on Facebook
    • Share on Twitter
    • Share on LinkedIn
    • Share on WhatsApp
Leave an answer

Leave an answer
Cancel reply

Browse

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 20df7
    2022-11-02T02:08:43+05:30Added an answer about 3 years ago

    1. SQL ORDER BY Clause:

    The SQL ORDER BY Clause is used in a SELECT statement to sort results either in ascending or descending order.

    Syntax for using SQL ORDER BY clause to sort data is:
    >SELECTcolumn-list FROM table_name ORDER BY column1, column2,.. columnN [DESC]];
    For Example:
    If you want to sort the employee table by salary of the employee, the SQL query would be.
    > SELECT name, salary FROM employee ORDER BY salary;
    By default, the ORDER BY Clause sorts data in  ascending order. If data to be sorted in descending order, the command would be as given below.
    > SELECT name, salary FROM employee ORDER BY name, salary DESC;

    2. SQL GROUP BY Clause:
    The SQL GROUP BY Clause is used with the group functions to retrieve data grouped according to one or more columns.

    The basic syntax of GROUP BY clause is given below. The GROUP BY clause must follow the conditions in the WHERE clause and must precede the ORDER BY clause if one is used.
    SELECT column1, column2 FROM table name WHERE [ conditions ]
    GROUP BY column1, column2
    ORDER BY column1, column2

    For Example:

    If you want to know the total amount of salary spent on each department, the query would be:
    > SELECT dept, SUM (salary) FROM employee GROUP BY dept;
    The group by clause should contain all the columns in the select list expect those used along with the group functions.
    > SELECT location, dept, SUM (salary) FROM employee GROUP BY location, dept;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 500k
  • Answers 393k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Aditi Dugal

    How to approach applying for a job at a company ...

    • 7 Answers
  • Raghavan Prasad Hayer

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Ankita Dinesh Biswas

    What is a programmer’s life like?

    • 5 Answers
  • 47e0c
    47e0c added an answer Correct Answer - Increasing the yield of animals and improving… November 12, 2022 at 9:56 am
  • b6699
    b6699 added an answer Sender\'s addressDateReceivers name and addressSubjectContentYours faithfullyName November 12, 2022 at 9:56 am
  • 10eb8
    10eb8 added an answer Any uncertinity in measurment is known as errorDifference in true… November 12, 2022 at 9:56 am

Related Questions

  • The units of length, velocity and force are doubled. Which ...

    • 1 Answer
  • The penetration of light into the region of geometrical shadow ...

    • 1 Answer
  • if ` veca , vecb ,vecc ` are three vectors ...

    • 1 Answer
  • What is the value of isothermal bulk modulus of elasticity ...

    • 1 Answer
  • निम्न में से किस अणु का सेवाधिक द्विध्रुव आघूर्ण है ...

    • 1 Answer

Top Members

Trending Tags

Class 11 Parabola Polity Polynomials Probability Projectile Protists Quadrilaterals Rario Reasoning Sampling Social Solutions Spectroscopy Switchgear Thermodynamic Tourism Transients Upsc Wbjee

Explore

  • Home
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Tags
  • Badges
  • Users

Footer

mcqoptions.com

About

MCQOptions.com

Here are the top interview questions, example answers, tips for giving the best response.

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Follow

© 2022 MCQOptions. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.