0
嗨,我創建一個查詢誰爲用戶跟隨我想要計數每個時間段的類別intersets。 但我沒有得到正確的結果與我的查詢。我不在哪裏是我的問題在查詢中。任何人都有想法如何解決它。如何使用sql server中的某個類別使用group來計數?
這是我的查詢=>
SELECT Name,count(SIF.InsertDateTime) as Count
FROM dbo.InteresetInFollowers SIF
INNER JOIN dbo.Users u on u.userid = sif.userid
INNER JOIN dbo.SubCategoryIn ss on ss.SubCategoryInId = SIF.SubCategoryInId
INNER JOIN dbo.CategoryIn s on s.CategoryInId = ss.CategoryInId
WHERE SIF.IsFollowed = 1
GROUP BY Name,SIF.InsertDateTime
My current o/p =>
Name | Count
Cricket 5000
reading 1000
My expacted o/p =>
Name | Count
Cricket 2
reading 3
Here In my data base like this data is store =>
CategoryIn =>
CategoryInId | Name
1 Cricket
2 reading
SubCategoryIn =>
SubCategoryInId | CategoryInId | Name
1 1 balling
2 1 batsman
3 2 baybal
4 2 story
InteresetInFollowers=>
InteresetInId | UserId | SubCategoryInId | IsFollow | InsertDateTime
1 10 1 1 2017-07-19 14:23:30.703
2 20 2 1 2017-07-19 14:23:30.703
3 30 3 1 2017-07-19 14:23:30.703
4 40 4 1 2017-07-19 14:23:30.703
5 50 3 1 2017-07-19 14:23:30.703
我需要得到的只是今天計數?使用日期條件如何做到這一點? –
我編輯了我的文本,檢查它。 – Dave94