1
00:01.130 --> 00:04.670
So today we are starting with T-sql.

2
00:06.620 --> 00:16.520
So basically T-sql is used for the programming to construct the programming kind of thing in SQL.

3
00:16.940 --> 00:23.930
Because whenever we are writing any SQL queries then it is not stored anywhere in the database, right?

4
00:23.930 --> 00:29.300
It is not stored anywhere in the database, so it is not reusable.

5
00:29.660 --> 00:32.360
T-sql queries is not reusable.

6
00:32.480 --> 00:41.510
So to construct that reusability stored procedure concept will come into the picture.

7
00:43.130 --> 00:44.270
And.

8
00:46.550 --> 00:51.080
To learn the store procedure we have to start with the what is the variable.

9
00:51.080 --> 00:54.260
And then conditional.

10
00:55.310 --> 00:57.200
What are the conditional statement.

11
00:57.200 --> 00:58.370
Then what is the looping.

12
00:58.370 --> 01:00.000
From that we have to start.

13
01:00.000 --> 01:03.420
So today we will start with basic thing.

14
01:03.720 --> 01:05.670
What is a variable.

15
01:09.750 --> 01:18.480
So variables variables are used to store the data temporarily temporarily for later use in the same

16
01:18.480 --> 01:20.820
batch in which they are declared.

17
01:21.660 --> 01:25.800
So I will let you know what is the same batch in which they are declared.

18
01:25.830 --> 01:30.480
Meaning batch is one or more T-sql statements.

19
01:30.690 --> 01:32.490
So what is a batch over here?

20
01:32.490 --> 01:42.690
It is a one or more multiple or single T-sql statement sent by a client application to SQL server for

21
01:42.720 --> 01:44.640
execution as one unit.

22
01:47.370 --> 01:49.530
Execution as one unit.

23
01:50.220 --> 01:54.480
So maybe there will be some front end application, right?

24
01:54.510 --> 02:04.140
There will be some front end application which may be either developed in Java or dotnet or something.

25
02:04.140 --> 02:08.610
So in which in the backend they are using the SQL right.

26
02:09.270 --> 02:13.950
In the backend they are using the SQL mostly.

27
02:13.980 --> 02:23.760
So at that time, whenever we are doing some kind of, uh, activity in the front end, uh, frontend

28
02:23.790 --> 02:31.680
application, and at that time it is calling some backend, uh, backend SQL.

29
02:31.680 --> 02:35.520
So in the back end it will be running one or more SQL statement.

30
02:35.550 --> 02:36.150
Right?

31
02:36.810 --> 02:43.320
Because in SQL backend side backend side only SQL statements will be available.

32
02:43.710 --> 02:50.220
So it will be at the end, it will be calling SQL statements and it will be written in some batch.

33
02:50.940 --> 02:54.630
Like in one batch there will be some statement.

34
02:56.970 --> 03:00.310
Some or single SQL.

35
03:02.320 --> 03:03.670
Statements are there, right?

36
03:03.790 --> 03:05.380
Then batch will be end.

37
03:05.740 --> 03:13.030
Then we are specifying either go or then again new batch may be start and maybe few more SQL statement

38
03:13.060 --> 03:13.840
may be start.

39
03:13.840 --> 03:16.060
So like this it will be stored.

40
03:17.140 --> 03:19.540
This is just simple demo example.

41
03:19.960 --> 03:22.570
Now how we can declare the variable.

42
03:22.570 --> 03:25.960
Let's see how we can declare the variable.

43
03:25.960 --> 03:28.150
We have to mention this keyword.

44
03:28.150 --> 03:33.040
Declare whatever is highlighted in blue over here.

45
03:33.040 --> 03:34.090
That is a keyword, right?

46
03:34.090 --> 03:41.200
Declare then variable name any variable name you can give as data type.

47
03:41.230 --> 03:45.520
We have to mention that mention the data type, right?

48
03:45.550 --> 03:51.310
Either it is a integer kind of variable or varchar kind of variable or decimal kind of variable.

49
03:51.550 --> 03:57.850
Because every column value will be stored, any any column value will be stored in the variable.

50
03:58.180 --> 04:01.180
So that column is also having a data type.

51
04:01.180 --> 04:01.780
Right.

52
04:01.840 --> 04:08.650
So that to store that column information for the variable also we need to specify.

53
04:08.980 --> 04:10.660
Data type over here.

54
04:12.670 --> 04:16.840
This is a one way or this optional.

55
04:16.840 --> 04:18.280
This is as keyword is.

56
04:18.310 --> 04:18.700
Optional.

57
04:18.700 --> 04:19.960
Over here this is second way.

58
04:19.960 --> 04:22.030
Also we can declare the variable.

59
04:22.210 --> 04:22.750
Right.

60
04:22.750 --> 04:23.650
This is the second way.

61
04:23.650 --> 04:25.930
Also we can declare the variable.

62
04:27.460 --> 04:33.580
Now let's say this is a variable I have declared declare at the rate x.

63
04:33.580 --> 04:38.230
This is x is what x is a variable name as integer.

64
04:40.960 --> 04:41.860
As integer.

65
04:41.860 --> 04:43.450
Right as integer.

66
04:43.750 --> 04:45.640
Now select.

67
04:45.640 --> 04:50.170
We have to either print or select or set this variable value.

68
04:50.200 --> 04:50.830
Right.

69
04:51.820 --> 04:58.700
This variable value we have to either print or Set or select.

70
04:58.700 --> 05:00.590
So over here I have done the select.

71
05:00.620 --> 05:03.650
Right select at the rate x as x.

72
05:03.680 --> 05:07.160
This is a column alias right column alias.

73
05:07.160 --> 05:14.180
But when I execute this query when I execute this query it will return me null.

74
05:17.090 --> 05:18.680
It will return me null.

75
05:18.860 --> 05:23.150
This is a column alias which is x and it is returning me null.

76
05:23.150 --> 05:23.420
Why?

77
05:23.420 --> 05:23.660
Why?

78
05:23.660 --> 05:28.640
It is returning me null because I haven't set the value of x.

79
05:29.510 --> 05:32.300
I have not set the value of x anywhere.

80
05:32.300 --> 05:39.200
If I do like this set at the rate x equal to ten.

81
05:39.830 --> 05:41.990
Now let me try what it is showing.

82
05:44.360 --> 05:45.500
Say over here.

83
05:45.530 --> 05:47.300
Now it is showing me ten.

84
05:47.300 --> 05:49.700
Right now it is showing me ten.

85
05:49.730 --> 05:50.930
Now let me try.

86
05:50.930 --> 05:55.200
If I mention like a will it give me a result?

87
05:58.020 --> 06:02.430
No conversion failed when converting the vertical value a to data type integer.

88
06:02.460 --> 06:02.940
Why?

89
06:03.240 --> 06:06.630
Because we have declared this variable as integer.

90
06:07.260 --> 06:10.920
We cannot specify a vertical value value over here, right?

91
06:11.010 --> 06:14.070
We cannot specify varchar value over here.

92
06:15.930 --> 06:18.510
Now let's see one more example.

93
06:18.780 --> 06:21.630
Now see this is a variable has been declared right.

94
06:21.660 --> 06:24.330
Declare at the rate x equal to integer.

95
06:24.510 --> 06:27.900
Now after that I have to specify over here go.

96
06:28.200 --> 06:30.780
After that I have to specify over go.

97
06:30.810 --> 06:32.370
So over here.

98
06:35.400 --> 06:37.260
Batch will start right.

99
06:37.290 --> 06:38.520
Batch will start.

100
06:39.270 --> 06:41.010
And whenever.

101
06:43.050 --> 06:43.800
You.

102
06:46.110 --> 06:47.460
Specify.

103
06:47.940 --> 06:51.210
Go at that time.

104
06:52.830 --> 06:55.800
Batch Which will end over here.

105
06:56.100 --> 07:03.300
So now if I mention select at the rate x equal to x, then say what will happen.

106
07:12.270 --> 07:15.150
Must declare the scalar variable at the rate x.

107
07:15.180 --> 07:15.780
Why?

108
07:16.350 --> 07:19.260
Because batch is already end over here.

109
07:19.260 --> 07:27.090
When we specify go command go statement then batch will specify batch will end over here.

110
07:27.090 --> 07:32.760
So after the batch will end you cannot use that particular variable right.

111
07:32.760 --> 07:34.980
You cannot use that particular variable.

112
07:35.010 --> 07:36.720
See what is written over here.

113
07:36.750 --> 07:39.450
Same batch in which they are declared.

114
07:39.480 --> 07:44.010
The later use in the same batch in which they are declared.

115
07:44.010 --> 07:46.680
But over here batch will be gone.

116
07:47.040 --> 07:48.360
Batch will be gone.

117
07:48.360 --> 07:51.210
So you cannot use that variable over here right

118
07:53.800 --> 07:59.140
You cannot use that variable over here in scope.

119
07:59.290 --> 08:02.200
Declaring variables one at a time.

120
08:02.230 --> 08:04.630
Declaring variables one at a time.

121
08:04.750 --> 08:09.730
Now see over here I have declared three variables.

122
08:09.730 --> 08:11.680
Over here I have declared three variables.

123
08:11.890 --> 08:15.010
Declare at the rate x is one variable.

124
08:15.010 --> 08:17.080
Which data type is integer?

125
08:18.130 --> 08:24.040
This is second variable y, which data type is worker and this is third variable.

126
08:24.040 --> 08:25.510
Which data type is date.

127
08:25.690 --> 08:31.390
So this is one variable I have declared at a time one variable at the rate x.

128
08:31.660 --> 08:33.100
Then second variable.

129
08:33.100 --> 08:40.870
So when this semicolon will be there at that time that one variable is over.

130
08:41.410 --> 08:43.930
Now you have to mention declare again.

131
08:46.180 --> 08:47.260
Declare again.

132
08:47.260 --> 08:56.990
And you can mention another variable Then again, when this semicolon is there, this one will be completed.

133
08:57.020 --> 09:02.840
After that, you have to declare, write it again and you will declare one more variable, right?

134
09:04.460 --> 09:06.470
We will declare one more variable.

135
09:09.710 --> 09:12.950
Now declaring multiple variables at a time.

136
09:13.040 --> 09:14.120
Now over here.

137
09:14.150 --> 09:19.940
See what is the change after this in place of semicolon I have mentioned comma.

138
09:20.930 --> 09:23.030
Now I do not need to write declare.

139
09:23.060 --> 09:23.690
Again.

140
09:24.380 --> 09:26.570
I do not need to write declare again.

141
09:26.900 --> 09:30.650
I can directly write at the rate y where k of ten.

142
09:33.050 --> 09:37.940
Then I can say either z s date.

143
09:38.090 --> 09:39.290
So this is.

144
09:39.290 --> 09:42.320
Multiple variables will be declared at a time.

145
09:42.530 --> 09:46.670
And this is declaring a variable at a single time.

146
09:47.030 --> 09:48.200
At one time.

147
09:51.020 --> 09:54.140
That is a difference in multiple and single.

148
09:54.290 --> 09:56.990
Now over here.

149
09:59.240 --> 10:08.990
If we do select let me try select at the rate x at the rate y at the rate z.

150
10:09.920 --> 10:11.630
What it will return.

151
10:13.010 --> 10:15.230
It will return null null null only right.

152
10:15.230 --> 10:16.460
It will return null null null.

153
10:16.490 --> 10:17.000
Why?

154
10:17.330 --> 10:21.620
Because I haven't set any value for all these three variables.

155
10:21.710 --> 10:25.430
I haven't set any value for all these three variables.

156
10:25.610 --> 10:32.060
So for that purpose say set statement will come into the picture for that purpose.

157
10:32.060 --> 10:34.670
Says statement will come into the picture.

158
10:34.670 --> 10:38.030
It is used to assign value to a variable.

159
10:38.030 --> 10:40.730
It is used to assign value to a variable.

160
10:42.230 --> 10:45.620
Only one variable is allowed at a time.

161
10:45.650 --> 10:52.110
Now see, I have declared all all the variable above.

162
10:52.290 --> 10:55.290
And now I have to set values like this.

163
10:56.490 --> 10:57.300
Declare.

164
10:57.780 --> 11:02.550
This line is for declaring all the three variables at multiple variables at a time.

165
11:02.910 --> 11:05.640
Ten set iterate x equal to 23.

166
11:05.670 --> 11:09.360
Set at the rate y equal to hello because it is worker.

167
11:09.360 --> 11:11.880
And over here we need to specify date.

168
11:12.150 --> 11:16.440
Now if I run this query it will give me proper result.

169
11:16.470 --> 11:20.310
See it will give me proper result right.

170
11:27.870 --> 11:31.260
Now at the time of declaration.

171
11:31.260 --> 11:35.970
Also I can initialize the value at the time of declaration.

172
11:35.970 --> 11:38.040
Also I can initialize the value.

173
11:38.070 --> 11:40.230
See over here what I am doing.

174
11:40.500 --> 11:42.870
Iterate x integer.

175
11:47.610 --> 11:49.110
Equal to 23.

176
11:49.140 --> 11:51.600
Let me check whether it will work or not.

177
11:54.960 --> 11:55.350
Okay.

178
11:55.350 --> 11:59.190
It is working now at the rate.

179
12:02.160 --> 12:03.030
Harshit.

180
12:03.180 --> 12:05.070
So now let me see what it is.

181
12:05.070 --> 12:05.490
Printing.

182
12:05.520 --> 12:06.150
Harshit or.

183
12:06.150 --> 12:06.780
Hello.

184
12:08.490 --> 12:08.940
Okay.

185
12:08.940 --> 12:09.750
It is printing.

186
12:09.750 --> 12:10.440
Hello.

187
12:10.680 --> 12:18.420
Now at the rate date equal to I, let me specify this particular date only.

188
12:22.290 --> 12:23.790
And let me write it over here.

189
12:23.820 --> 12:25.770
Now let me remove all these three.

190
12:25.800 --> 12:27.240
Now see what I am doing.

191
12:27.240 --> 12:29.130
I am removing all these three.

192
12:29.250 --> 12:31.500
Now see what it will show.

193
12:33.030 --> 12:34.530
23 Harshit.

194
12:34.530 --> 12:36.060
And this date.

195
12:36.090 --> 12:36.810
Right.

196
12:39.540 --> 12:45.030
So this is initialization of a variable value at the time of declaration.

197
12:45.030 --> 12:49.120
Only initialization the variable by declaring the variable.

198
12:49.150 --> 12:50.800
This is the same thing, right?

199
12:54.100 --> 12:59.050
Now we can also assign the values to a variable using a Select statement.

200
12:59.080 --> 13:04.540
We can also assign the values to a variable using a Select statement.

201
13:04.570 --> 13:05.380
How?

202
13:06.520 --> 13:09.850
Now I have declared over here three variables right.

203
13:10.660 --> 13:12.670
Employee name, job and salary.

204
13:12.700 --> 13:13.750
Employee name.

205
13:13.750 --> 13:14.830
Job and salary.

206
13:14.860 --> 13:15.490
Right.

207
13:17.530 --> 13:20.290
Now select employee name.

208
13:21.550 --> 13:24.430
Now over here we need to identify.

209
13:24.430 --> 13:26.710
You have to write the select statement.

210
13:26.890 --> 13:34.240
So in this particular employee name you want to store the value of employee name column from employee

211
13:34.270 --> 13:34.480
one.

212
13:34.480 --> 13:38.530
Table right name column from the employee one table.

213
13:38.560 --> 13:40.780
Now in this edit job.

214
13:40.810 --> 13:48.530
Edit job variable you want to store the value of job column Average salary you want to store the value

215
13:48.530 --> 13:57.620
of salary column and from from MP one where MP number equal to this this this.

216
13:57.620 --> 13:58.190
Right.

217
13:58.190 --> 13:59.750
So let me show you.

218
13:59.780 --> 14:09.710
Select e name comma job comma salary from MP one.

219
14:17.300 --> 14:19.220
Now both of these statement.

220
14:19.250 --> 14:23.930
Now I have to select over here again to display the value of this one.

221
14:23.960 --> 14:28.040
This one and this one variable value we have to show right.

222
14:28.070 --> 14:29.990
Variable value we have to show.

223
14:30.590 --> 14:36.800
So I can see both of the query will give me same result right.

224
14:36.830 --> 14:39.530
Both of the query will give me same result

225
14:46.100 --> 14:46.520
Right.

226
14:46.520 --> 14:52.190
So using select statement also we can assign a value to the variable right.

227
14:55.460 --> 14:56.600
One minute.

228
15:01.100 --> 15:02.990
Now let's move forward.

229
15:04.730 --> 15:08.090
Now suppose if multiple rows qualify.

230
15:08.660 --> 15:11.510
If multiple rows qualify then.

231
15:11.540 --> 15:15.440
Then when assign assignment select is finished.

232
15:15.470 --> 15:20.180
The value in the variables are those from the last row.

233
15:20.960 --> 15:23.900
The SQL server happened to access.

234
15:24.020 --> 15:27.770
Now see what is the thing over here.

235
15:27.860 --> 15:31.460
We have to copy this same SQL statement.

236
15:33.200 --> 15:38.930
And over here let me write dept number dept equal to ten.

237
15:39.620 --> 15:45.000
Now how many rows this query will give me For Rose.

238
15:45.000 --> 15:46.380
It is giving me right over here.

239
15:46.380 --> 15:48.480
Multiple values are qualified, right?

240
15:48.660 --> 15:50.490
Multiple rows are qualified.

241
15:50.520 --> 15:50.760
Right.

242
15:50.790 --> 15:51.900
Multiple rows.

243
15:51.960 --> 15:57.420
So at that time, what will happen if I execute this query.

244
15:59.070 --> 16:01.920
See over here it is last row.

245
16:01.920 --> 16:04.170
It is returning me last row.

246
16:05.730 --> 16:07.290
Not all the rows.

247
16:07.890 --> 16:08.670
Why?

248
16:10.710 --> 16:14.400
Because this select statement will.

249
16:15.090 --> 16:18.150
We haven't specified either in a loop condition.

250
16:18.150 --> 16:18.720
Right?

251
16:18.750 --> 16:26.940
Either in loop condition or any kind of cursor or any kind of procedure we haven't used.

252
16:28.260 --> 16:33.000
So that reason it will loop through only single row.

253
16:33.000 --> 16:33.840
Only it will.

254
16:33.870 --> 16:36.300
It will loop through only single row only.

255
16:36.450 --> 16:37.590
And it will.

256
16:37.740 --> 16:42.600
Giving me only last row from the SQL server happened to access.

257
16:42.940 --> 16:45.010
So say, what is the last row over here?

258
16:45.040 --> 16:45.460
Harry.

259
16:46.120 --> 16:47.560
Harry is my last row.

260
16:47.560 --> 16:48.610
So only last row.

261
16:48.610 --> 16:51.760
It will give you not all the rows, right?

262
16:53.470 --> 17:00.190
That cannot be possible over here in simple print or select statement.

263
17:00.520 --> 17:03.610
Now let me see what will happen over here.

264
17:05.350 --> 17:16.120
Now when you specify over here as a select statement, it will it will retrieve the last row.

265
17:16.150 --> 17:19.060
But over here using a set statement.

266
17:19.060 --> 17:26.860
Also you you will set the values of particular variable using the select statement as well.

267
17:26.860 --> 17:32.320
Using the set statement as well, we are setting the value of a variable, right.

268
17:32.770 --> 17:35.440
But over here there will be one problem.

269
17:35.470 --> 17:37.090
See what is the problem

270
17:49.510 --> 17:51.070
See what is the problem.

271
17:51.970 --> 17:54.760
Subquery written more than one value.

272
17:54.790 --> 17:57.130
Subquery written more than one value.

273
17:57.160 --> 18:02.890
This is not permitted when the subquery for rows equal to or less not equal to, less than, less than

274
18:02.890 --> 18:08.740
or equal to, greater than, greater than or equal to, or when the subquery is used as an expression.

275
18:09.100 --> 18:13.810
So you have to just remember one thing while your.

276
18:22.330 --> 18:29.710
You have to remember one thing while your subquery will return more than one value, while your subquery

277
18:29.710 --> 18:31.690
will return more than one value.

278
18:31.780 --> 18:35.020
This query is returning more than one row, right?

279
18:35.110 --> 18:36.820
More than one row.

280
18:36.940 --> 18:37.810
Right?

281
18:38.650 --> 18:41.540
More than one row at that time.

282
18:41.540 --> 18:43.970
You cannot use the set.

283
18:44.000 --> 18:44.870
Set.

284
18:44.990 --> 18:49.370
You cannot set the variable value using a set command.

285
18:50.000 --> 18:51.680
You cannot use the.

286
18:51.710 --> 18:55.190
You cannot set the variable value using a set command.

287
18:55.820 --> 19:06.140
Either you have to specify the select statement or you have to specify the looping.

288
19:07.490 --> 19:12.830
So it is not possible over here when you are using a set statement.

289
19:13.670 --> 19:18.830
But but if it is a single value see if it is a single value.

290
19:18.860 --> 19:21.410
Let me show you MP number.

291
19:21.500 --> 19:27.380
So where we have used this one right over here it will retrieve only single value.

292
19:27.410 --> 19:28.040
Right.

293
19:28.490 --> 19:31.130
Over here it will retrieve only single value.

294
19:31.160 --> 19:32.840
Let me change over here.

295
19:37.220 --> 19:39.290
And now let me try to run

296
19:42.320 --> 19:43.730
See over here.

297
19:43.760 --> 19:44.450
Over here.

298
19:44.480 --> 19:48.710
A single value I have used and I have commented this two thing.

299
19:48.710 --> 19:50.810
I have commented this two thing.

300
19:50.810 --> 19:53.360
So this 7839.

301
19:53.390 --> 19:55.010
Employee name is king.

302
19:55.010 --> 19:56.930
So king it will retrieve me.

303
19:56.930 --> 19:57.590
King.

304
19:58.010 --> 20:02.330
Because this subquery is not returning me more than one value, right?

305
20:02.780 --> 20:09.470
This subquery is not returning me more than one value, but this subquery will return me more than one

306
20:09.470 --> 20:09.770
value.

307
20:09.800 --> 20:11.960
That is why it is failing, right?

308
20:14.540 --> 20:20.900
So to show you the error only I have actually I have to write it over here.

309
20:25.670 --> 20:26.690
One minute.

310
20:32.540 --> 20:34.670
Over here in the set clause we are seeing.

311
20:34.670 --> 20:35.000
Right.

312
20:35.000 --> 20:37.370
So I have to mention it over here.

313
20:38.150 --> 20:40.590
And I have to comment that thing.

314
20:41.340 --> 20:42.870
Now let's see.

315
20:45.210 --> 20:46.080
See over here.

316
20:46.110 --> 20:48.060
Same thing King is displaying now.

317
20:48.060 --> 20:48.660
Right.

318
20:48.810 --> 20:52.950
Because this subquery is returning me only single value right.

319
20:54.690 --> 20:57.990
But this one is returning me multiple values.

320
20:57.990 --> 21:00.000
That is why it is giving me error.

321
21:07.320 --> 21:08.190
Right.

322
21:10.590 --> 21:13.380
Now see what what this will return.

323
21:13.590 --> 21:16.260
Declare at the rate salary, money.

324
21:16.650 --> 21:23.730
So I have declared the variable salary cell variable with money data type set salary equal to select

325
21:23.730 --> 21:24.630
statement.

326
21:25.290 --> 21:28.050
So what is the salary of 7839.

327
21:28.620 --> 21:30.930
What is the this SQL statement.

328
21:30.960 --> 21:33.630
Right I have to write it one minute.

329
21:36.510 --> 21:38.570
I have to copy this one.

330
21:42.200 --> 21:45.440
And if I run both of this query, it will give me the same result.

331
21:45.470 --> 21:46.100
Right?

332
21:47.000 --> 21:47.960
5000.

333
21:47.960 --> 21:48.830
5000.

334
21:53.750 --> 21:56.360
Now let me see over here.

335
21:56.360 --> 21:57.740
This query will not fail.

336
21:57.770 --> 21:58.490
Right.

337
21:58.580 --> 21:59.330
Over here.

338
21:59.330 --> 22:00.560
This query will not fail.

339
22:00.560 --> 22:03.710
It will because it is retrieving me single value.

340
22:04.730 --> 22:06.440
The inner query will be retrieving me.

341
22:06.440 --> 22:07.280
Single value.

342
22:07.310 --> 22:08.120
Single.

343
22:09.080 --> 22:10.670
Single employee.

344
22:10.940 --> 22:12.050
Employee name.

345
22:12.050 --> 22:13.160
Single employee.

346
22:13.190 --> 22:14.090
Job detail.

347
22:14.120 --> 22:16.040
Single employee salary.

348
22:16.670 --> 22:18.560
So it will not fail, right?

349
22:20.030 --> 22:26.720
But if we mention department number equal to ten, 20 or 30, then it will be fail, right?

350
22:28.940 --> 22:31.160
Now there is one print statement.

351
22:31.160 --> 22:32.240
Is there print.

352
22:34.910 --> 22:37.420
So using a select statement.

353
22:37.420 --> 22:42.820
Also, sometimes we see the value and using a print statement.

354
22:42.820 --> 22:46.180
Also we see the value of a result set right.

355
22:46.180 --> 22:50.380
So it is used to return a user defined message to the client.

356
22:50.980 --> 22:51.700
So print.

357
22:51.730 --> 22:52.420
Hello.

358
22:52.570 --> 22:55.090
So what it will do print hello.

359
22:56.950 --> 23:00.880
It will simply print hello and see.

360
23:00.880 --> 23:05.350
This time messages is coming over here not table kind of thing.

361
23:05.680 --> 23:07.390
Have you noticed this one.

362
23:08.050 --> 23:15.100
It is showing something like messages and in messages it is showing hello, not table kind of thing

363
23:15.130 --> 23:16.390
now.

364
23:16.510 --> 23:22.120
But if I do like this select see the difference over here.

365
23:22.150 --> 23:26.110
Select get date and print get date.

366
23:26.140 --> 23:30.850
Now let me run both of the query same time okay.

367
23:30.850 --> 23:33.340
Now this is showing me is a table.

368
23:34.210 --> 23:42.480
This is showing me as a table write column name is given no column name and see when I run this one,

369
23:42.990 --> 23:44.280
what is display over here?

370
23:44.280 --> 23:47.520
It is displays as a message.

371
23:49.020 --> 23:51.450
It is displayed as a message, right?

372
23:54.240 --> 23:55.740
Now let me unmute you.

373
23:57.720 --> 23:58.050
Okay.

374
23:58.050 --> 24:00.090
Now let's see the programs.

375
24:00.120 --> 24:02.310
Write a program to add two numbers.

376
24:02.310 --> 24:03.810
So I have declared one variable.

377
24:03.810 --> 24:05.730
Declare a an integer.

378
24:05.850 --> 24:09.900
Then again I have specify comma so I can declare another variable.

379
24:09.900 --> 24:11.400
Declare b as integer.

380
24:11.550 --> 24:13.110
Declare c as integer.

381
24:13.140 --> 24:15.150
Now my one statement is over.

382
24:15.150 --> 24:17.460
So I have mentioned the semicolon over here.

383
24:17.490 --> 24:18.090
Write.

384
24:18.240 --> 24:27.300
One statement is over right now, at the rate we have to set the value of at the rate a 100, at the

385
24:27.300 --> 24:32.820
rate B 200, and at the rate C equal to what at the rate a plus at the rate b.

386
24:33.060 --> 24:36.800
So print c See we have to print this z value right.

387
24:36.800 --> 24:40.160
So it will print what it will print 300.

388
24:40.160 --> 24:40.820
Right.

389
24:41.750 --> 24:42.590
See.

390
24:46.250 --> 24:50.810
It is printing three 300 or either printing say.

391
24:50.840 --> 24:53.090
Let me try to mention select.

392
24:54.350 --> 24:57.080
Select address.

393
24:57.110 --> 25:00.500
See this should also work.

394
25:00.500 --> 25:01.640
Let me try.

395
25:01.730 --> 25:05.930
See now this time it is showing as a tabular format right.

396
25:06.440 --> 25:08.240
It is a tabular format right.

397
25:11.090 --> 25:16.100
Now write a program to take the input date and print the day of the week.

398
25:16.910 --> 25:20.480
So now over here we need to give some input.

399
25:20.630 --> 25:24.440
So for the input we need to mention the date right.

400
25:24.650 --> 25:25.970
Some kind of date.

401
25:25.970 --> 25:32.570
And we want the what is the what is either it is a Sunday Monday Tuesday Wednesday Thursday.

402
25:32.690 --> 25:34.650
We want to mention like that.

403
25:35.190 --> 25:42.330
So to store the date value, we have to declare one variable at the rate D, and because of date, the

404
25:42.330 --> 25:43.410
data type will be date.

405
25:43.410 --> 25:48.780
Right now we have to set the value of this at the date D.

406
25:49.050 --> 25:56.220
So what is set D equal to some 15th August 1947.

407
25:57.300 --> 26:01.410
Now how we can get the date name.

408
26:01.440 --> 26:05.640
We have seen this function while seeing the date function right.

409
26:05.640 --> 26:08.790
So date name day of the week.

410
26:08.850 --> 26:12.030
And at the rate in which day of the week?

411
26:12.030 --> 26:17.340
Which value of day of the week you want to see that we have to mention over here.

412
26:17.370 --> 26:26.310
So it will give you see Friday on 15th August 1947.

413
26:26.310 --> 26:32.010
It was a Friday when India got independence right

414
26:35.830 --> 26:38.890
Now let's see one more program.

415
26:43.210 --> 26:49.900
Write a program to take AMP number and print corresponding name and salary from AMP one table.

416
26:51.910 --> 27:02.260
Now you have to think while reading this line which kind of variable you have to declare that should

417
27:02.380 --> 27:04.000
come into your mind.

418
27:04.870 --> 27:06.760
This should be come into your mind.

419
27:06.760 --> 27:08.200
So what is my requirement?

420
27:08.230 --> 27:10.480
Write a program to take amp number.

421
27:10.600 --> 27:18.460
So one variable we have to take that is that can store the value of amp number somewhere right.

422
27:19.120 --> 27:22.450
And what we need to print we need to print name.

423
27:26.500 --> 27:28.750
And we need to print salary

424
27:31.570 --> 27:34.030
Name and salary and MP number.

425
27:34.030 --> 27:36.370
So these three variables we need to declare.

426
27:36.400 --> 27:37.300
Right.

427
27:38.230 --> 27:39.160
So what.

428
27:39.190 --> 27:44.980
Declare e number e integer e name where k of 20 and salary money.

429
27:45.100 --> 27:48.430
Now I have set the value of 7839.

430
27:49.390 --> 27:53.230
So I need to put the value of MP number right.

431
27:53.500 --> 28:01.420
And then what I have to do, I have to set the value of e name and set the value of salary.

432
28:01.870 --> 28:06.790
But for which employee I have to set for this particular employee.

433
28:06.790 --> 28:10.450
Only for this particular employee.

434
28:10.450 --> 28:10.840
And Louis.

435
28:10.840 --> 28:18.100
And this, this result is stored in this E number variable.

436
28:18.130 --> 28:18.730
Right.

437
28:18.850 --> 28:21.910
So in the where condition I have to specify E number.

438
28:21.910 --> 28:22.540
Right.

439
28:23.560 --> 28:25.720
And now I have to print.

440
28:28.450 --> 28:35.780
Print e name and salary for this particular employee number over here.

441
28:35.780 --> 28:37.160
I have mentioned the.

442
28:38.120 --> 28:40.460
Now let me show you one more thing.

443
28:42.500 --> 28:48.710
Print edit in E name plus.

444
28:51.230 --> 28:52.130
Plus.

445
28:52.280 --> 28:52.790
Address.

446
28:52.790 --> 28:53.390
Cell.

447
28:53.780 --> 28:57.770
Now what will be the problem over here if I use this one?

448
28:59.420 --> 29:02.660
I am trying to do concat between between.

449
29:03.290 --> 29:07.250
I am trying to do concrete between two different variables.

450
29:08.240 --> 29:09.800
Two different variables.

451
29:09.800 --> 29:18.290
Data type one is money and one is worker, one is money and one is worker.

452
29:18.320 --> 29:21.530
So that it this statement will give me error.

453
29:27.140 --> 29:35.070
For this purpose I have to do cast right for that purpose, I have to do cast as a salary.

454
29:38.550 --> 29:42.240
For that purpose, I have to use cast as salary.

455
29:46.590 --> 29:47.910
Now it will.

456
29:48.210 --> 29:49.560
Don't give me any error.

457
29:49.560 --> 29:49.800
Right?

458
29:49.830 --> 29:50.130
It will.

459
29:50.130 --> 29:51.600
Don't give me any error.

460
29:57.300 --> 29:58.140
Right.

461
29:58.920 --> 30:01.740
Now both of this data type in Varchar only.

462
30:01.770 --> 30:03.570
Right in Varchar only.

463
30:10.320 --> 30:15.960
Now let's see one more thing and then we will conclude.

464
30:16.800 --> 30:23.070
Write a program to in input write a program to input EMP number.

465
30:23.430 --> 30:26.640
So my first variable will be EMP number right

466
30:29.910 --> 30:31.290
And print.

467
30:34.410 --> 30:35.340
In print.

468
30:35.370 --> 30:37.170
Employee experience.

469
30:37.380 --> 30:42.360
Experience in employee table.

470
30:42.390 --> 30:42.990
Right.

471
30:45.270 --> 30:47.340
So second variable value.

472
30:47.370 --> 30:50.850
We have to declare higher date.

473
30:50.880 --> 30:52.080
We have to store somewhere.

474
30:52.080 --> 30:52.650
Right.

475
30:53.100 --> 30:56.970
Higher date we have to show store somewhere.

476
30:57.060 --> 30:58.140
So for.

477
31:07.890 --> 31:10.890
For that purpose also we need to declare one more variable.

478
31:10.920 --> 31:11.520
Right.

479
31:12.060 --> 31:18.120
For that purpose also we need to declare one more variable and we need to display experience.

480
31:24.600 --> 31:28.640
So for that purpose also we need to declare one more variable.

481
31:29.720 --> 31:33.050
So this will become my three variable.

482
31:37.790 --> 31:38.870
Date of joining.

483
31:38.900 --> 31:42.710
We need to store higher date so it will be in the date data type.

484
31:42.740 --> 31:51.740
Experience we need to show in the in the integer ten years of experience or 20 years of experience like

485
31:51.740 --> 31:52.310
that.

486
31:52.760 --> 31:56.840
Now I have set the value of 7839.

487
31:57.590 --> 31:59.060
Then select edit.

488
32:00.680 --> 32:02.090
Select edit.

489
32:02.120 --> 32:05.900
Dog I need to store higher date as well.

490
32:06.440 --> 32:07.700
Now experience.

491
32:07.700 --> 32:09.110
How can I set?

492
32:10.400 --> 32:12.920
How can I set the experience?

493
32:13.250 --> 32:14.720
We need to.

494
32:16.550 --> 32:19.730
We have a higher date and we have a two days date.

495
32:19.910 --> 32:21.590
This is my higher date.

496
32:22.040 --> 32:24.020
This is my two days date.

497
32:24.260 --> 32:27.010
And we need difference in here.

498
32:29.590 --> 32:31.450
We need difference in here, right?

499
32:31.450 --> 32:33.100
We need difference in here.

500
32:34.660 --> 32:39.070
So that datediff function we have to use.

501
32:42.250 --> 32:46.120
This will tell me the difference between this and this in here.

502
32:46.510 --> 32:47.800
Now print.

503
32:49.930 --> 32:54.970
Experience equal to cast because of this experience is in integer right.

504
32:56.680 --> 32:59.620
Because of this experience is in integer.

505
32:59.770 --> 33:03.460
We have to cast this in work again right.

506
33:03.460 --> 33:06.430
So when I run execute this query see.

507
33:10.750 --> 33:13.390
43 years of experience.

508
33:14.620 --> 33:19.390
This king has this king has 43 years of experience.

509
33:19.390 --> 33:20.020
Right