ADBMS Assignment 1
ADBMS Assignment 1
e) List the names of all employees those having reading as a second hobby.
f) List employee names for those who have joined between 30 June and 31 Dec
2015.
company> db.employee.distinct("designation");
[ 'Analyst', 'Clerk', 'Manager', 'Salesman' ]
h) List the eid,ename,salary of all employees whose salary is less than 10000.
j) List the all employees whose name start with "A" letter.
l) List the all employees whose names either start or end with “S”.
company> db.employee.distinct("designation").length;
4
q) List the eid,ename of all employees whose salary is gretter than or equal to
15000.
s) List the names of employees those having reading and painting hobbies.
company> db.employee.find({ hobbies: { $all: ["reading", "painting"] } },
{ ename: 1, _id: 0 });
[ { ename: 'Alice' }, { ename: 'Charlie' }, { ename: 'Grace' } ]
t) List the first hobby of all employees from the employee collection.
company> db.employee.find({}, { ename: 1, hobbies: { $slice: 1 }, _id: 0 })
[
{ "ename": "Alice", "hobbies": ["reading"] },
{ "ename": "Bob", "hobbies": ["travelling"] },
{ "ename": "Charlie", "hobbies": ["painting"] },
{ "ename": "David", "hobbies": ["reading"] },
{ "ename": "Eve", "hobbies": ["sports"] },
{ "ename": "Frank", "hobbies": ["travelling"] },
{ "ename": "Grace", "hobbies": ["reading"] },
{ "ename": "Henry", "hobbies": ["travelling"] },
{ "ename": "Ivy", "hobbies": ["reading"] },
{ "ename": "Jack", "hobbies": ["reading"] }
]
u) List the names of all employees those having three different hobbies.
company>db.employee.find({ hobbies: { $size: 3 } }, { ename: 1, _id: 0 })
[
{ ename: 'Jack' }
]