0% found this document useful (0 votes)
6 views

Assign 2

This issue is that I am not working on this code for the current course field and science indapur mathematics and science indapur mathematics and science indapur mathematics and

Uploaded by

bidafo2019
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Assign 2

This issue is that I am not working on this code for the current course field and science indapur mathematics and science indapur mathematics and science indapur mathematics and

Uploaded by

bidafo2019
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 12

1)Find employees having designation as either "HR" or "Software tester"

Company> db.Employee.find({$or: [{ Designation: "HR" },{ Designation: "Software


tester" }]})
[
{
_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'
},
{
_id: ObjectId('656aadb335f588e519c30789'),
'Employee ID': '10',
'First Name': 'Stive',
'Last Name': 'martin',
Email: '[email protected]',
'Phone No.': '+9198xxxxxx',
Address: {
'House No': '12',
Street: 'bhavnagar',
City: 'dilhi',
State: 'dilhi',
Country: 'India',
'Pin-code': '612013'
},
Salary: 80000,
Designation: 'Software tester',
Skills: [ 'sylynium', 'Testing', 'pinterresting' ],
Experience: 3,
'Project name': 'Project X',
'Project experience': 'Testing Projects',
'Date of Joining': '2020-01-15',
Birthdate: '2000-06-22'
}
]

--------
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 “”.

Company> db.Employee.find({$or: [ { "First Name": "Rushi" },{ "Last Name":


"Honkande" } ]})
[
{
_id: ObjectId('656a9ba235f588e519c30780'),
'Employee ID': '1',
'First Name': 'Rushi',
'Last Name': 'Honkande',
Email: '[email protected]',
'Phone No.': '+917030237805',
Address: {
'House No': '2',
Street: 'yashwantnagar',
City: 'Akluj',
State: 'maharastra',
Country: 'India',
'Pin-code': '413118'
},
Salary: 60000,
Designation: 'Software Engineer',
Skills: [ 'Python', 'JavaScript', 'SQL' ],
Experience: 2,
'Project name': 'Project X',
'Project experience': 'Developed backend systems',
'Date of Joining': '2021-01-15',
Birthdate: '2001-09-20'
}
]
----------
3)Find all transaction having payment successful status.
Company> db.Transaction.find({
... "Payment.Payment Successful": true
... })
[
{
_id: ObjectId('656ab06d35f588e519c3078a'),
'Transaction Id': '123456',
'Transaction Date': '2023-12-01',
Name: 'John',
'Transaction Details': [
{
'Item Id': 'item001',
'Item Name': 'Bag',
Quantity: 2,
Price: 300
},
{
'Item Id': 'item002',
'Item Name': 'brush',
Quantity: 1,
Price: 40
}
],
Payment: {
Type: 'Debit',
'Total amount paid': 640,
'Payment Successful': true
},
Remark: 'Transaction processed successfully.'
},
{
_id: ObjectId('656ab49c35f588e519c3078b'),
'Transaction Id': '1',
'Transaction Date': '2023-12-01',
Name: 'Manoj Mane',
'Transaction Details': [
{
'Item Id': 'item001',
'Item Name': 'Bag',
Quantity: 2,
Price: 300
},
{
'Item Id': 'item002',
'Item Name': 'brush',
Quantity: 1,
Price: 40
}
],
Payment: {
Type: 'Debit',
'Total amount paid': 640,
'Payment Successful': true
},
Remark: 'Transaction processed successfully.'
},
{
_id: ObjectId('656ab4a635f588e519c3078c'),
'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.'
},
{
_id: ObjectId('656ab4a635f588e519c3078d'),
'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.'
}
]

----------

4)Find all details of transaction done by “ Sagar Vyvahare ” employee.


Company> db.Transaction.find({"Name": "Sagar Vyvahare"})
[
{
_id: ObjectId('656ab4a635f588e519c3078d'),
'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.'
}
]
5)Find all employees having skills ‘Javascript’,’Python’.
db.Employee.find({Skills: { $all: ["Java", "Python"] }})
Company> db.Employee.find({Skills: { $all: [ "Python", "JavaScript"] }})
[
{
_id: ObjectId('656a9ba235f588e519c30780'),
'Employee ID': '1',
'First Name': 'Rushi',
'Last Name': 'Honkande',
Email: '[email protected]',
'Phone No.': '+917030237805',
Address: {
'House No': '2',
Street: 'yashwantnagar',
City: 'Akluj',
State: 'maharastra',
Country: 'India',
'Pin-code': '413118'
},
Salary: 60000,
Designation: 'Software Engineer',
Skills: [ 'Python', 'JavaScript', 'SQL' ],
Experience: 2,
'Project name': 'Project X',
'Project experience': 'Developed backend systems',
'Date of Joining': '2021-01-15',
Birthdate: '2001-09-20'
}
]

-----

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"})

Q)Get sum of all salaries from collection Employee.

db.Employee.aggregate([{$group: {_id: null,totalSalary: { $sum: "$Salary" }}}])

Q)Find details of employee having maximum salary


db.Employee.find().sort({ "Salary": -1 }).limit(1)
Company> db.Employee.find().sort({ "Salary": -1 }).limit(1)
[
{
_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 details of employee having minimum salary


Company> db.Employee.find().sort({ "Salary": 1 }).limit(1)
[
{
_id: ObjectId('656aadb335f588e519c30783'),
'Employee ID': '4',
'First Name': 'Manish',
'Last Name': 'Shah',
Email: '[email protected]',
'Phone No.': '+917433745637',
Address: {
'House No': '12',
Street: 'Shiwajinagar',
City: 'Pune',
State: 'maharastra',
Country: 'India',
'Pin-code': '412005'
},
Salary: 20000,
Designation: 'Frontend intern',
Skills: [ 'HTML', 'JavaScript', 'css' ],
Experience: 0,
'Project name': 'Project b',
'Project experience': 'Fresher',
'Date of Joining': '2023-08-15',
Birthdate: '2003-05-25'
}
]
Q)Find total amount paid by employee in all transactions.

]
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 }
]

Q)Find total quantity of item id 23434


db.Transaction.aggregate([{$unwind: "$Transaction Details"},{$match: {"Transaction
Details.Item Id": "23434"}},{$group: {_id: null,totalQuantity: { $sum:
"$Transaction Details.Quantity" }}}])

Company> db.Transaction.aggregate([{$unwind: "$Transaction Details"},{$match:


{"Transaction Details.Item Id": "item001"}},{$group: {_id: null,totalQuantity:
{ $sum: "$Transaction Details.Quantity" }}}])
[ { _id: null, totalQuantity: 4 } ]

Q)Find details of transaction having item quantity less than 3


Company> db.Transaction.find({"Transaction Details.Quantity": { $lt: 3 }})
[
{
_id: ObjectId('656ab06d35f588e519c3078a'),
'Transaction Id': '123456',
'Transaction Date': '2023-12-01',
Name: 'John',
'Transaction Details': [
{
'Item Id': 'item001',
'Item Name': 'Bag',
Quantity: 2,
Price: 300
},
{
'Item Id': 'item002',
'Item Name': 'brush',
Quantity: 1,
Price: 40
}
],
Payment: {
Type: 'Debit',
'Total amount paid': 640,
'Payment Successful': true
},
Remark: 'Transaction processed successfully.'
},
{
_id: ObjectId('656ab49c35f588e519c3078b'),
'Transaction Id': '1',
'Transaction Date': '2023-12-01',
Name: 'Manoj Mane',
'Transaction Details': [
{
'Item Id': 'item001',
'Item Name': 'Bag',
Quantity: 2,
Price: 300
},
{
'Item Id': 'item002',
'Item Name': 'brush',
Quantity: 1,
Price: 40
}
],
Payment: {
Type: 'Debit',
'Total amount paid': 640,
'Payment Successful': true
},
Remark: 'Transaction processed successfully.'
},
{
_id: ObjectId('656ab4a635f588e519c3078c'),
'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.'
},
{
_id: ObjectId('656ab4a635f588e519c3078d'),
'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 the details of transaction having minimum quantity price.


Company> db.Transaction.find().sort({ "Transaction Details.Price": 1 }).limit(1)
[
{
_id: ObjectId('656ab06d35f588e519c3078a'),
'Transaction Id': '123456',
'Transaction Date': '2023-12-01',
Name: 'John',
'Transaction Details': [
{
'Item Id': 'item001',
'Item Name': 'Bag',
Quantity: 2,
Price: 300
},
{
'Item Id': 'item002',
'Item Name': 'brush',
Quantity: 1,
Price: 40
}
],
Payment: {
Type: 'Debit',
'Total amount paid': 640,
'Payment Successful': true
},
Remark: 'Transaction processed successfully.'
}
]

You might also like