Ravindra BagaleCourses & study guides Track your progress

5. ORDER BY, DISTINCT आणि Top-N निकाल

5.2 दोन कॉलमने क्रम (शहर मग रक्कम)

का (Why). Managers ना शहर ग्रुप्स, मग प्रत्येक शहरात रक्कम हवी असते.

काय (What). ORDER BY city, amount_inr DESC आधी शहर, मग रक्कम.

कसं (How). क्रम कीज डावीकडून उजवीकडे — पहिली की टाय ब्रेक करते.

पायऱ्या

  1. city ASC.
  2. दुसरी की amount DESC.
  3. निकालात एक शहर ब्लॉक बघा.

उदाहरणे

उदाहरण 1 · dataset: raja_coffee

SELECT city, amount_inr
FROM orders
ORDER BY city ASC, amount_inr DESC
LIMIT 12;

Output

cityamount_inr
Goa890.0
Goa360.0
Goa350.0
Kolhapur900.0
Kolhapur890.0
Kolhapur620.0
Mumbai930.0
Mumbai840.0
Mumbai720.0
Nashik1080.0
Nashik890.0
Nashik350.0

Meaning. शहरे अक्षरक्रमाने; प्रत्येक शहरात मोठ्या रकमा आधी.

Ravindra Bagale's Tip

You can mix ASC and DESC per column.