このクエリの作成を開始しましたが、質問を閉じる必要がある理由を理解するのが難しいことがわかりました。
select
TOP ##Limit:int?38369## -- The maximum value the hardware can handle.
Posts.Id as [Post Link], -- Question title.
Count(PendingFlags.PostId) as [Number of pending flags], -- Number of pending flags per questions.
Posts.OwnerUserId as [User Link], -- Let click on the colum to see if the same user ask off-topic questions often.
Reputation as [User Reputation], -- Interesting to see that such questions are sometimes asked by high rep users.
Posts.Score as [Votes], -- Interesting to see that some questions have more than 100 upvotes.
Posts.AnswerCount as [Number of Answers], -- I thought we shouldn't answer on off- topic post.
Posts.FavoriteCount as [Number of Stars], -- Some questions seems to be very helpfull :) .
Posts.CreationDate as [Asked on], -- The older is the question, the more is the chance that flags on them can't get reviewed.
Posts.LastActivityDate as [last activity], -- Similar effect as with Posts.CreationDate.
Posts.LastEditDate as [modified on],
Posts.ViewCount
from posts
LEFT OUTER JOIN Users on Users.id = posts.OwnerUserId
INNER JOIN PendingFlags on PendingFlags.PostId = Posts.Id
where ClosedDate IS NULL -- The question is not closed.
group by Posts.id, Posts.OwnerUserId, Reputation, Posts.Score, Posts.FavoriteCount, Posts.AnswerCount, Posts.CreationDate, Posts.LastActivityDate, Posts.LastEditDate, Posts.ViewCount
order by Count(PendingFlags.PostId) desc; -- Questions with more flags have more chance to get them handled, and the higher is the probabilty that the question is off-topic (since several users already reviewed the question).
質問ごとにいくつかのフラグがあることを考えると、単純な表を使用して各フラグに使用される理由をフラグに示すことはできませんが、各投稿の CloseReasonTypes.Id の最も一般的な値を表示することは適切であると思います: this 2つの問題に私を導きます:
最初に:このクエリを確認した後、 CloseReasonTypesをPendingFlagsに結合して、番号ではなく理由の名前を表示する必要があります。PostsとPendingFlagsの間に共通のフィールドがないため、テーブルを結合するためのベースとして使用しているため、このJOIN
from posts
を行う方法についての手がかりがありません。2番目: 各行で最も一般的に使用される終了理由を選択する方法がわかりません。同様のケースについていくつかの質問が議論されているようですが、テーブル全体で最も一般的な値を見つける方法を尋ねているため、回答を使用できません。その結果、単一の列と単一の行を持つテーブルになります。各投稿のフラグの数に対してこれを行います。