Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
0 Now, let us start with the order by command 1
This command will help us sort our results, so till now we have been filtering our resultset, we have been applying 2
filters 3
To get particular data, which is specifying particular conditions 4
Now the result that we have received, we want to sort it in a particular order, to sort the data we'll use 5
Order by 6
How to use order by 7
Select the columns from the table name 8
Put the condition if you want to 9
So that is an optional part, then you write order by 10
And then you tell the column name with which you want to order it 11
Then you you specify in ascending order or in the descending order 12
It is possible that you specify more than one column 13
And you can specify 14
And you can specify whether you want to do ascending descending 15
Ordering with column 1 and ascending descending order with column 2 16
That is also possible, we will see that in the examples 17
So in the first example 18
What we are trying to get is 19
If you want to find out all the customers 20
Who 21
Reside in the state of California 22
And 23
We want that result to be ordered by the customer name 24
If I just write order by customer name 25
It will automatically order it in the ascending order 26
If I write this ASC keyword also 27
It will 28
Do the same thing, so both of these commands are same 29
Let's go and write this command and see what is the result that we get 30
We want to find out everything select star 31
From customer 32
Where the state 33
Is California 34
And we want to order it by 35
The customer name 36
Let us run this command 37
So you can see 38
You Scroll it to the right 39
All these customers have the state California, this was specified in the where condition 40
And 41
The customer names 42
Are arranged in the alphabetical order so first 43
Is Allen 44
Then comes 45
Customer with name starting with B then comes customer with name starting with c 46
And so on 47
So they are 48
Arranged alphabetically 49
In Ascending order 50
If you want to arrange them in descending order 51
Just add the keyword for descending 52
Order by 53
Customer name 54
Then you specify the keyword 55
Descending DESC 56
So you can see 57
The Customer names are now in descending order, with starting with Z 58
Then Y 59
Then X and if you go down it will be ending with 60
Customer name starting with A 61
You can give two column names at the same time while ordering 62
If you want to 63
First 64
Order the data 65
With city in ascending order 66
And then you want to arrange the data according to the customer name in descending order 67
That can also to be done 68
So 69
Let us start writing that query 70
We will order the 71
Data in ascending order with city name and descending with 72
Customer name 73
Order by 74
City 75
ASC 76
By 77
Customer name descending 78
Run this query 79
First look at the City part 80
This 81
You can see cities are arranged in ascending order 82
Starting with A going down 83
Then comes B C and so on 84
The first two have the same city 85
So their customer name 86
Is arranged in descending order, you first get a customer name is starting with M then you get 87
Starting with e 88
Same is with the next 89
City 90
That's how first it is sorting the data using the city column 91
In ascending order 92
Then it is arranging the data 93
In descending order with the customer name 94
While ordering the data 95
Instead of mentioning the column name you can also specify the column number 96
You can write something like this 97
Order by 98
This is the column number 2 99
In our data column number 2 is customer name, So if you like this it will 100
Order the data in descending order 101
With customer name 102
And you can also use 103
Columns which are non textual so if you use a column which has 104
Age which will be an integer 105
It will order the integers in ascending or descending order so 106
Let's do both of this things 107
So let's order this data using the column number 108
Which is 2 109
Order by 2 110
Ascending 111
You can see 112
This is ordered in the 113
The customer name, which is the column number 2 114
Is used to 115
Sort the data in ascending order 116
Now let us sort 117
Sort 118
The customers 119
Basis their age 120
We have the customers who have maximum age on top and minimum at the bottom 121
So We'll be arranging them in the descending order 122
Order by age 123
Descending DESC 124
Run it 125
You can see 126
There are several customers 127
With age 128
70 then comes 69 and so on 129
So 130
Both strings and integers can be used to sort the data 131
If it is a string it will be sorted in a to z Or z to a manner basis the 132
Keyword you have used ascending or descending 133
If it is a integer 134
It Will be arranged in smallest to largest or largest to smallest 135
Basis the ascending descending that you have specified 136
If you have not specified anything it will be ascending by default 137
That's how we Sort the data 138
In the next video 139
We'll learn how to limit the 140
Number of rows that we are getting back when we run a query
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.