Assign 2
Assign 2
--------
2)Find all employees working on same project.
Company> db.Employee.find({"Project name": "AI"})
[
{
_id: ObjectId('656aadb335f588e519c30784'),
'Employee ID': '5',
'First Name': 'Magesh',
'Last Name': 'Ladage',
Email: '[email protected]',
'Phone No.': '+9174302275543',
Address: {
'House No': '36',
Street: 'swarupnagar',
City: 'Solapur',
State: 'maharastra',
Country: 'India',
'Pin-code': '410021'
},
Salary: 65000,
Designation: 'HR',
Skills: [ 'Communication', 'Interpersonal Skills', 'Data Science' ],
Experience: 5,
'Project name': 'AI',
'Project experience': 'Tesm Lead',
'Date of Joining': '2017-01-15',
Birthdate: '1988-01-25'
},
{
_id: ObjectId('656aadb335f588e519c30786'),
'Employee ID': '7',
'First Name': 'Anil',
'Last Name': 'Patil',
Email: '[email protected]',
'Phone No.': '+919855734323',
Address: {
'House No': '56',
Street: 'bhartiwadi',
City: 'Pune',
State: 'maharastra',
Country: 'India',
'Pin-code': '412056'
},
Salary: 80000,
Designation: 'HR',
Skills: [ 'Communication', 'Data Analysis' ],
Experience: 5,
'Project name': 'AI',
'Project experience': 'Hired Emplyees',
'Date of Joining': '2025-01-15',
Birthdate: '1991-01-25'
}
]
--------
3)Find all details of employee having name “” Rushi Honkande “”.
----------
-----
Find all details of all transactions having transaction on date “”. (except _id)
Company> db.Transaction.find({ "Transaction Date": "2020-10-11"},{ _id: 0 })
[
{
'Transaction Id': '23434',
'Transaction Date': '2020-10-11',
Name: 'Mangesh ladage',
'Transaction Details': [
{
'Item Id': 'item002',
'Item Name': 'table',
Quantity: 1,
Price: 500
}
],
Payment: {
Type: 'cash',
'Total amount paid': 500,
'Payment Successful': true
},
Remark: 'Transaction processed successfully.'
},
{
'Transaction Id': '23434',
'Transaction Date': '2020-10-11',
Name: 'Sagar Vyvahare',
'Transaction Details': [
{
'Item Id': 'item004',
'Item Name': 'RC car',
Quantity: 1,
Price: 1000
}
],
Payment: {
Type: 'cash',
'Total amount paid': 1000,
'Payment Successful': true
},
Remark: 'Transaction processed successfully.'
}
]
----------
Q.)Find name, id, birthdate of all employees
Company> db.Employee.find( {}, { "First Name": 1, "Last Name": 1, "Employee ID": 1,
"Birthdate": 1, _id: 0 })
[
{
'Employee ID': '1',
'First Name': 'Rushi',
'Last Name': 'Honkande',
Birthdate: '2001-09-20'
},
{
'Employee ID': '2',
'First Name': 'Sagar',
'Last Name': 'Vyahare',
Birthdate: '2001-01-25'
},
{
'Employee ID': '3',
'First Name': 'Vishal',
'Last Name': 'Patil',
Birthdate: '2001-01-01'
},
{
'Employee ID': '4',
'First Name': 'Manish',
'Last Name': 'Shah',
Birthdate: '2003-05-25'
},
{
'Employee ID': '5',
'First Name': 'Magesh',
'Last Name': 'Ladage',
Birthdate: '1988-01-25'
},
{
'Employee ID': '6',
'First Name': 'Monoj',
'Last Name': 'Mane',
Birthdate: '2001-01-25'
},
{
'Employee ID': '7',
'First Name': 'Anil',
'Last Name': 'Patil',
Birthdate: '1991-01-25'
},
{
'Employee ID': '8',
'First Name': 'Monoj',
'Last Name': 'Mane',
Birthdate: '2001-01-25'
},
{
'Employee ID': '9',
'First Name': 'dylial',
'Last Name': 'sygle',
Birthdate: '1996-01-20'
},
{
'Employee ID': '10',
'First Name': 'Stive',
'Last Name': 'martin',
Birthdate: '2000-06-22'
}
Q)Find details of employees having salary more than 80000
Company> db.Employee.find({ Salary: { $gt: 80000 } })
[
{
_id: ObjectId('656aadb335f588e519c30788'),
'Employee ID': '9',
'First Name': 'dylial',
'Last Name': 'sygle',
Email: '[email protected]',
'Phone No.': '+09132343233',
Address: {
'House No': '55',
Street: 'st.john ',
City: 'mankind',
State: 'LA',
Country: 'US',
'Pin-code': '23422345'
},
Salary: 120000,
Designation: 'Team leader',
Skills: [
'Interpersonal Skills',
'Data Analysis',
'Interpersonal Skills',
'Team leading'
],
Experience: 4,
'Project name': 'Project X',
'Project experience': 'Developed fullstack systems',
'Date of Joining': '2018-01-15',
Birthdate: '1996-01-20'
}
]
-----------
Q.Find all details of transaction having status ‘Done’.
db.Transaction.find({Status:"Done"})
]
Company> db.Transaction.aggregate([{$group: {_id: "$Name",totalAmountPaid: { $sum:
"$Payment.Total amount paid" }}}])
[
{ _id: 'Mangesh ladage', totalAmountPaid: 500 },
{ _id: 'John', totalAmountPaid: 640 },
{ _id: 'Manoj Mane', totalAmountPaid: 640 },
{ _id: 'Sagar Vyvahare', totalAmountPaid: 1000 }
]