0%

random

Repeat practice practice practice

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using System;
public Static class NullUtil
{
public static bool IsNull(this object x)
{

return x == null;
}
}
public class Test
{
static void Main()
{
object y = null;
Console.writeLine(y.IsNull());
y= new object();
Console.WriteLine(y.IsNull());
}
}

1-1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
create table squeezable(random_text varchar2(50))
/
declare

i binary_integer;
j binary_integer;
l binary_integer;
v_string varchar2(50);
begin
for i in 1 .. 10000
loop
j :=dbms_random.value(1,100);
v_string :=dbms_random.string('U',50);
while(j<length(v_string))
loop
k :=dbms_random.value(1,3);
v_string :=substr(substr(v_string,1,j)||rpad('',k)
||substr(v_string,j+1),1,50);
j :=dbms_random.value(1,100);
end loop;
insert into squeezable
values(v_string);
end loop;
commit;
end;
/

1-2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
update accounts
set balance = balance - purchased_amount
where balance >= purchased_amount
and credit_limit >= purchased_amount
and expiry_date > today()
and customer_id = provided_id
and card_num = provided_cardnum

select c.customer_id,a.card_num,a.expiry_date,
a.credit_limit,a.balance
from customers c
left outer join accounts a
on a.customer_id = c.customer_id
and a.card_num = provided_cardnum
where c.customer_id = provied_id


​```SQL
select custname
from customers
where city ='GOTHAM'
and custid in
(select o.custid
from orders o,
(select distinct od.ordid from orderdetail od,
articles a
where a.artname='BATMOBILE'
and a.artid = od.artid)x
where o.ordered >= somefunc
and x.ordid = o.ordid)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
INSERT INFO your_table(column_namel,column_name2,...)
VALUES('value1','value2',...)

1-1
INSERT INTO my_contacts
(last_name,first_name,email,gender,birthday,professional,location,status,interests,seeking)
VALUES
('Anderson','Jillian','jill_anderson@breakneckpizza.com','F','1980-09-05','Technical Writer','PaloAlto,CA', 'Single','Kayaking, Reptiles','Relationship,Friends');

1-2
var query = from user in SampleData.AllUsers
from project in SampleData.AllProjects
select new { User = user,Project = project};
foreach (var pair in query)
{
Console.WriteLine("{0}/{1}",
pair.User.Name,
pair.Project.Name)
}

1-3
var query = from defect in SampleData.AllDefects
where defect.AssignedTo != null
group defect by defect.AssignedTo;

foreach (var entry in query)
{
Console.WriteLine(entry.Key.Name);
foreach (var defect in entry)
{
Console.WriteLine(" ({0}) {1}",
defect.Severity, defect.Summary);
}
Console.WriteLine();
}