More queries

2 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€43.49
List Price:  €60.89
You save:  €17.40
£37.19
List Price:  £52.07
You save:  £14.87
CA$68.32
List Price:  CA$95.66
You save:  CA$27.33
A$77.04
List Price:  A$107.87
You save:  A$30.82
S$64.25
List Price:  S$89.96
You save:  S$25.70
HK$392.41
List Price:  HK$549.41
You save:  HK$156.99
CHF 40.84
List Price:  CHF 57.18
You save:  CHF 16.34
NOK kr497.74
List Price:  NOK kr696.88
You save:  NOK kr199.13
DKK kr324.40
List Price:  DKK kr454.18
You save:  DKK kr129.78
NZ$83.04
List Price:  NZ$116.27
You save:  NZ$33.22
د.إ183.58
List Price:  د.إ257.03
You save:  د.إ73.44
৳6,111.35
List Price:  ৳8,556.39
You save:  ৳2,445.03
₹4,323.81
List Price:  ₹6,053.68
You save:  ₹1,729.87
RM212.48
List Price:  RM297.49
You save:  RM85.01
₦77,222.05
List Price:  ₦108,117.05
You save:  ₦30,895
₨14,159.87
List Price:  ₨19,824.96
You save:  ₨5,665.08
฿1,631.17
List Price:  ฿2,283.77
You save:  ฿652.60
₺1,976.59
List Price:  ₺2,767.39
You save:  ₺790.79
B$275.09
List Price:  B$385.16
You save:  B$110.06
R904.92
List Price:  R1,266.96
You save:  R362.04
Лв84.97
List Price:  Лв118.96
You save:  Лв33.99
₩68,760.68
List Price:  ₩96,270.46
You save:  ₩27,509.77
₪175.17
List Price:  ₪245.25
You save:  ₪70.08
₱2,860.60
List Price:  ₱4,005.07
You save:  ₱1,144.46
¥7,239.76
List Price:  ¥10,136.24
You save:  ¥2,896.48
MX$949.23
List Price:  MX$1,328.99
You save:  MX$379.76
QR182.04
List Price:  QR254.87
You save:  QR72.83
P668.06
List Price:  P935.34
You save:  P267.28
KSh6,458.70
List Price:  KSh9,042.70
You save:  KSh2,584
E£2,526.86
List Price:  E£3,537.81
You save:  E£1,010.95
ብር6,738.65
List Price:  ብር9,434.65
You save:  ብር2,696
Kz45,588.63
List Price:  Kz63,827.73
You save:  Kz18,239.10
CLP$47,160.37
List Price:  CLP$66,028.30
You save:  CLP$18,867.92
CN¥359.34
List Price:  CN¥503.11
You save:  CN¥143.76
RD$2,959.52
List Price:  RD$4,143.56
You save:  RD$1,184.04
DA6,516.01
List Price:  DA9,122.93
You save:  DA2,606.92
FJ$112.39
List Price:  FJ$157.35
You save:  FJ$44.96
Q383.79
List Price:  Q537.34
You save:  Q153.54
GY$10,450.82
List Price:  GY$14,631.99
You save:  GY$4,181.16
ISK kr6,245.75
List Price:  ISK kr8,744.55
You save:  ISK kr2,498.80
DH455.66
List Price:  DH637.97
You save:  DH182.30
L856.07
List Price:  L1,198.56
You save:  L342.49
ден2,673.67
List Price:  ден3,743.35
You save:  ден1,069.68
MOP$404.03
List Price:  MOP$565.68
You save:  MOP$161.64
N$891.38
List Price:  N$1,248
You save:  N$356.62
C$1,837.13
List Price:  C$2,572.13
You save:  C$735
रु6,891.86
List Price:  रु9,649.16
You save:  रु2,757.29
S/180.26
List Price:  S/252.38
You save:  S/72.11
K206.02
List Price:  K288.44
You save:  K82.42
SAR187.55
List Price:  SAR262.58
You save:  SAR75.03
ZK1,216.52
List Price:  ZK1,703.23
You save:  ZK486.70
L218.80
List Price:  L306.34
You save:  L87.53
Kč1,079.18
List Price:  Kč1,510.94
You save:  Kč431.76
Ft17,557.41
List Price:  Ft24,581.78
You save:  Ft7,024.36
SEK kr479.39
List Price:  SEK kr671.18
You save:  SEK kr191.79
ARS$58,114.13
List Price:  ARS$81,364.44
You save:  ARS$23,250.30
Bs346.56
List Price:  Bs485.21
You save:  Bs138.65
COP$206,567.57
List Price:  COP$289,211.13
You save:  COP$82,643.55
₡25,165.96
List Price:  ₡35,234.35
You save:  ₡10,068.39
L1,307.23
List Price:  L1,830.23
You save:  L523
₲399,171.13
List Price:  ₲558,871.53
You save:  ₲159,700.39
$U2,048.82
List Price:  $U2,868.51
You save:  $U819.69
zł185.98
List Price:  zł260.38
You save:  zł74.40
Already have an account? Log In

Transcript

To work with more complex queries, we need to have more complex data. So I have a file here called sales dash data dot docs, the extension doesn't matter. But if you look at the file carefully, this is not a JSON array. For example, JSON fields must have double quoted text. And also an array must start with a square bracket. And every JSON object must have a comma.

But this is just a collection of JSON objects, one object per line. So let's import the same into a MongoDB collection. For that, let's issue the command Mongo import. And the DB is test two dB. And the file that we want to use happens to be called sales data dot docs. If you don't mention the collection name, the base name of the file will be used which is sales dash data.

Now I would like to have this as a collection called sales. So I'll say your data collection sales. And when I press enter, you will see that it has imported 286 document. Let's go and have a look into that in the Mongo shell. So we have the sales and the DB dot sales dot find. And then we'll use a pretty format to predefined the same thing, we can see that all the documents are lined up with an automatically generated underscore ID.

Now, it is important to see that we have some numerical fields such as quarter and sales amount, etc. Now let's work on this and execute some more complex queries. Let's say we want to query for our sales collection and get all the sales where the sales amount is more than or equal to $10,000. So the query would look something like DB dot sales dot find and the query is on the sale. Command, so as a sales amount, and then we use a another object and say dollar gt E, and then the amount which is $10,000. itself.

And if you want to prettify the output, let's call the PDF function as well save it. And then I'll say, Mongo less than x zero phi dot j s, and we get a bunch of documents that satisfy that condition.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.