1 00:00:00,660 --> 00:00:03,120 Hello there welcome. 2 00:00:03,150 --> 00:00:12,290 In this video we will be limiting and then sold tindale to retrieve from a database. 3 00:00:12,300 --> 00:00:14,840 Why do we need to limit data. 4 00:00:15,120 --> 00:00:24,660 Well often databases and they tables can get very large and may require or searchers retrieving only 5 00:00:24,660 --> 00:00:29,170 parts of the information from a table at a certain time. 6 00:00:29,460 --> 00:00:38,580 Well we can achieve this using Eskew school so we use the select clause the WHERE clause and then be 7 00:00:38,670 --> 00:00:44,960 ordered by to achieve the limiting and sorting of data. 8 00:00:45,600 --> 00:00:57,480 Let's assume we've had a fictitious request from the boss's big company we work for and they have just 9 00:00:57,540 --> 00:01:03,340 had a windfall and will like to give some cash. 10 00:01:03,390 --> 00:01:15,780 We however do only one and give the cash to employees who earn less than twelve thousand dollars or 11 00:01:15,780 --> 00:01:17,800 pounds in a year. 12 00:01:17,880 --> 00:01:27,120 So they come to us as a database administrator or analyst to get that data for them. 13 00:01:27,500 --> 00:01:33,810 So we are going to try and get that information from them. 14 00:01:33,840 --> 00:01:44,520 I have got to add for a Editor open and I have written a script or rescue a query that will get the 15 00:01:44,520 --> 00:01:46,750 information we require. 16 00:01:46,860 --> 00:01:49,860 I just need to explain this query too. 17 00:01:50,580 --> 00:02:00,180 So we start with the select statement and then we select the necessary columns from the Employees Table 18 00:02:00,450 --> 00:02:07,740 so we select the employee I.D. the first name last name and salary. 19 00:02:07,740 --> 00:02:12,510 You always separate the columns in the query by a comma. 20 00:02:12,600 --> 00:02:16,820 So you put a comma after each column apart from the last column. 21 00:02:17,010 --> 00:02:24,760 So we've got our columns here we've got the idea in the first name last name and then salary and then 22 00:02:24,760 --> 00:02:33,530 in the From field we have to tell s cool where to get the information from which is the Employees Table. 23 00:02:33,630 --> 00:02:39,730 Next we use the WHERE clause to field to that table. 24 00:02:39,750 --> 00:02:42,650 We don't want all the data return from that table. 25 00:02:42,780 --> 00:02:48,210 We only want setting data based on certain criteria. 26 00:02:48,210 --> 00:02:57,100 The criteria we've set is that any one who has the summary less than twelve thousand dollars or pounds. 27 00:02:57,120 --> 00:02:59,460 Those are the only details we want. 28 00:02:59,460 --> 00:03:04,600 So it will return anyone who might use this criteria. 29 00:03:04,920 --> 00:03:10,710 Ben wise you've got the data we now coming on the next you say order but we won't. 30 00:03:10,740 --> 00:03:21,210 All we want the data to be filtered all sorted in salary order sorted by salary and then we won in the 31 00:03:21,210 --> 00:03:22,830 descending order. 32 00:03:22,830 --> 00:03:30,150 That is from top to bottom descending means we will start with a higher salary and filter down to the 33 00:03:30,150 --> 00:03:30,980 lowest. 34 00:03:31,090 --> 00:03:33,960 So now let's execute the query. 35 00:03:34,110 --> 00:03:43,740 Always remember to end your queries with semi quinolone so executed that you will run Excel and so we've 36 00:03:43,740 --> 00:03:48,570 got 98 people who matches that criteria. 37 00:03:48,610 --> 00:03:54,640 So going to have 98 people who were going to get some kind of bullets in their salary right. 38 00:03:54,750 --> 00:04:02,670 So what we do know is a salary is been sorted or ordered in descending order. 39 00:04:02,700 --> 00:04:08,640 That's what is descending it will order in from top to bottom so you got 11. 40 00:04:08,640 --> 00:04:15,050 Five hundred eleven hundred and then the lawyers is to 100. 41 00:04:15,360 --> 00:04:16,330 That's quite low. 42 00:04:16,530 --> 00:04:18,180 Okay so we've got the data. 43 00:04:18,180 --> 00:04:25,480 How do we get this information to the bosses so to do that. 44 00:04:25,530 --> 00:04:26,240 Go to. 45 00:04:26,330 --> 00:04:29,250 They say it's export data set. 46 00:04:29,250 --> 00:04:34,260 Click on that and then you can select the format. 47 00:04:34,470 --> 00:04:38,170 Most people have got Excel so are set to excel. 48 00:04:38,590 --> 00:04:41,750 And then here you give the file name. 49 00:04:41,790 --> 00:04:44,750 So I've given the file salary. 50 00:04:44,940 --> 00:04:50,820 So you will be saved onto my desktop or the rest you can leave as default. 51 00:04:50,850 --> 00:04:52,670 And then click or key. 52 00:04:53,100 --> 00:04:59,920 So if I look on my desktop now I should have a file cause salaries excel and see that. 53 00:05:00,120 --> 00:05:08,950 This as a father so I can now send this far to the direct or the bosses based on this information the 54 00:05:09,230 --> 00:05:17,930 day will issue bonuses to be relevant people bago So this is the data that I have export to exported 55 00:05:17,930 --> 00:05:20,480 from the table database table. 56 00:05:20,690 --> 00:05:31,070 All right so or so I can now send this to the boss in this vigil we limited day to using the word class 57 00:05:31,370 --> 00:05:37,080 and all SOOL sorted data using the order by clause. 58 00:05:37,100 --> 00:05:40,180 I hope the information individual has been helpful. 59 00:05:40,340 --> 00:05:42,290 Thank you so much for watching. 60 00:05:42,290 --> 00:05:42,980 Bye for now.