1
00:00.200 --> 00:02.120
Let's see another SQL problem.

2
00:02.560 --> 00:04.680
Find the employees manager name.

3
00:05.000 --> 00:06.600
So below is the problem statement.

4
00:06.600 --> 00:13.480
Given a single table of employees that contains employee ID, employee name, and manager ID.

5
00:14.640 --> 00:19.480
Write a query to get a list of all employees in the name of their corresponding manager.

6
00:19.960 --> 00:24.880
So now let me just ask the same thing to the ChatGPT.

7
00:30.800 --> 00:32.560
So let me ask.

8
00:39.240 --> 00:45.960
I am having below table structure and data.

9
00:49.120 --> 00:51.840
So it will say please share your table structure and data.

10
00:52.000 --> 00:53.360
Let me share it.

11
00:54.960 --> 01:00.560
Now given a single table of employee that contains this this this write a query.

12
01:00.600 --> 01:06.720
Let let me just ask this one to get list of all employees in the name of their corresponding manager,

13
01:07.240 --> 01:07.480
right?

14
01:07.520 --> 01:09.320
I am just asking this one now.

15
01:10.320 --> 01:11.720
So let's see.

16
01:16.280 --> 01:17.000
Okay.

17
01:17.040 --> 01:17.840
Perfect.

18
01:18.800 --> 01:22.440
Now, let me copy the same thing over in the SQL.

19
01:22.920 --> 01:23.680
And let's see.

20
01:24.160 --> 01:27.960
Let's compare the result of both.

21
01:31.360 --> 01:36.320
So see Ankit manager is we can say boss Kapil manager is boss.

22
01:36.320 --> 01:36.800
Perfect.

23
01:36.800 --> 01:38.520
Pre-inca manager is manager.

24
01:39.000 --> 01:40.400
Boss manager is null.

25
01:41.600 --> 01:42.800
Boss manager is null.

26
01:42.800 --> 01:45.960
And we can say manager.

27
01:47.240 --> 01:47.880
Manager.

28
01:47.880 --> 01:49.360
Manager is boss, right?

29
01:49.720 --> 01:51.640
So it is giving the perfect result.

30
01:51.680 --> 01:52.800
This is the, uh.

31
01:53.760 --> 01:59.520
This one we can say solution provided by the.

32
02:02.600 --> 02:03.200
ChatGPT.

33
02:03.240 --> 02:03.840
Right.

34
02:03.840 --> 02:07.160
But now one thing, one problem is over here.

35
02:07.520 --> 02:10.320
I don't want null in the manager column.

36
02:10.760 --> 02:13.720
So that is not provided by the ChatGPT, right?

37
02:14.440 --> 02:16.680
That thing is not provided by ChatGPT.

38
02:16.720 --> 02:24.080
See, it is also showing null over here as well and it is provided only a single solution, right?

39
02:24.200 --> 02:30.440
So now you should be able to solve this problem.

40
02:30.440 --> 02:33.840
So let me ask the ChatGPT the same thing.

41
02:35.960 --> 02:47.600
Can you provide some default manager name where null is there in in the.

42
02:49.800 --> 02:52.000
Manager column.

43
02:52.720 --> 02:53.320
Right.

44
02:54.080 --> 02:58.560
So let's see whether ChatGPT will able to answer the question or not.

45
03:03.000 --> 03:03.520
Okay.

46
03:03.560 --> 03:04.120
Perfect.

47
03:04.160 --> 03:05.280
Now let's see.

48
03:06.240 --> 03:07.600
And let's copy the.

49
03:10.000 --> 03:12.080
Solution provided by ChatGPT.

50
03:12.080 --> 03:15.280
And let's see what happens.

51
03:17.240 --> 03:21.360
Perfect C boss has no any no any manager.

52
03:21.360 --> 03:21.800
Right.

53
03:22.080 --> 03:23.520
Boss has no any manager.

54
03:23.520 --> 03:27.600
So what it has done it has used the Isnull function.

55
03:27.600 --> 03:32.120
So whenever the in the employee name column it is null.

56
03:32.120 --> 03:36.360
It will provide the no manager value right.

57
03:36.440 --> 03:37.360
By default.

58
03:38.040 --> 03:45.400
So this is how you should able to, uh, counter question the ChatGPT like this, right?

59
03:46.840 --> 03:51.760
And I have already explained you that how this query will work, right?

60
03:53.520 --> 03:58.560
It will check it will create actually one table, but it will create two different tables.

61
03:58.560 --> 04:00.360
One is employee.

62
04:00.400 --> 04:05.920
We have to assume it will not create, but we have to assume one is employee table is there.

63
04:05.920 --> 04:12.560
One is employee table is there in in the employee table it will check for each of the manager ID it

64
04:12.560 --> 04:18.320
will check where it is available in the employee table as employee ID column.

65
04:18.840 --> 04:19.320
Right.

66
04:19.760 --> 04:24.080
That what I have explained you over here in the last two questions.

67
04:24.560 --> 04:33.560
And it will pick up that particular particular employee name which is actually the manager name from

68
04:33.560 --> 04:35.280
the employee table.

69
04:35.280 --> 04:35.760
Right.

70
04:39.240 --> 04:42.480
So this is how it will work.

71
04:42.480 --> 04:43.680
We can say right.

72
04:44.200 --> 04:47.080
So we will see the next question into the next lecture.

73
04:47.080 --> 04:47.720
Thank you.