這個問題可能措辭不當,但這是我的問題。我有一個MySQL查詢,查找哪個用戶已經從庫中檢出了大部分書籍。 SQL查詢工作得很好,但我是品牌spankin'MongoDB世界的新手。這是我的SQL查詢:你如何找到MongoDB字典中發生最多的字段?
SELECT UID, count(UID)
FROM checkout_data
GROUP BY UID
ORDER BY count(UID) desc
LIMIT 1;
我該如何在Mongo中執行此操作? 編輯:實例庫
{
"Date_Checked_Out":" 2014-01-01 09:34:36.206",
"Day":"Wednesday",
"Borrower_Category":" Undergraduate Student",
"Item_Barcode":"00000000'",
"Title":" Bob's Day at the Beach",
"Material_Format":" BOOK",
"Loan_Policy applied to item":" 0.10Day 2Week Loan",
"Due_Date":" 2013-12-19 00:45:00.0",
"Due_Day":"Thursday",
"Number_times_renewed":" 0",
"Institution":"FREED HARDEMAN UNIV; LODEN-DANIEL LIBR",
"Home_Branch": 15243,
"Shelving_Location":" Stacks; 1st Floor",
"Call_Number":" BV640 .B37 1989",
"UID":" 15243ea5-421f-4cec-b091-394586adfe2b"
}
請問您可以在集合中發佈樣本文檔嗎? – BatScream 2014-12-05 01:30:19
當然!感謝BatScream。 – 2014-12-05 01:51:09