Should SQL challenges (performance-related or otherwise) be considered on topic for this site? By "SQL challenge" I mean attempting to solve a problem using SQL that may not have any immediate, real world application. In some cases it could be obvious that SQL is the wrong choice of language for the problem. I think that a strict interpretation of the rules would consider these to be off topic, but I find them to be a fun way to be exposed to new ways of solving problems and to develop technical skills.

To try to better explain what I mean here, I would define a challenge as writing code for the sake of writing code. I know the example questions below weren't closed, but I'm asking for the sake of future questions that might be asked. For example, consider dynamic data masking in SQL Server. I think that asking for queries which can quickly unmask data of a certain type would be an interesting exercise. Do I have a practical need for such an answer? No, I'm not a malicious hacker. Could I create a fake scenario for such a question? Sure, I could say something like "My boss is convinced that dynamic data masking will protect our data. Is it possible to write a very efficient data that unmasks all of the data?" Is that scenario necessary for it to be on topic?

Here are some examples of what I would describe as SQL challenges:

What are different ways to replace ISNULL() in a WHERE clause that uses only literal values?

How can I convert the first 100 million positive integers to strings?

  • do you want the reasons in the answers or as comments?
    – John K. N.
    Commented Sep 1, 2017 at 6:11
  • Can we have a protected tag for the challenges?
    – John K. N.
    Commented Sep 1, 2017 at 6:58
  • 2
    @hot2use I imagine there would be a follow up meta question about how best to implement challenges once (if) we establish topicality
    – Paul White Mod
    Commented Sep 1, 2017 at 7:38
  • 2
    @hot2use The answers are community wikis, so feel free to edit. It would also be fine to post your own answer if you want to do that.
    – Joe Obbish
    Commented Sep 1, 2017 at 15:22
  • 2
    How do we decide when to decide this?
    – Hannah Vernon Mod
    Commented Sep 1, 2017 at 20:53
  • 3
    @MaxVernon How is consensus determined on Meta sites?
    – Paul White Mod
    Commented Sep 2, 2017 at 3:24

4 Answers 4


Yes, SQL Challenges should be considered on topic because...

  • they provide the community with new approaches to existing problems.

  • they show the more exotic forms of SQL, and are an invaluable way to hone your craft.

  • they are popular and may attract new expert users to the site

  • We love fun



SQL Challanges (as described in the question) are neither automatically on-topic, nor off-topic.

Each question should be evaluated on its merits by the community.

I would expect questions of this type to be well-received, if they:

  • Fit in Q & A format
  • Are clearly presented and explained
  • Contain sufficient information to identify correct answers
  • Invite answers based on expertise and experience, rather than personal opinion
  • Produce content with long-term value
  • 1
    "Produce content with long-term value" -- well, there go all my answers. Commented Oct 17, 2017 at 11:50

No, SQL Challenges should be considered off topic because...


No, but continue to allow moderator/community discretion for questions that don't quite fit, but produce sufficiently interesting answers.

Worth noting is that neither question you have linked is closed. A question that starts "What are different ways to…" is a red flag for other reasons, whether it is on-topic or not, which just goes to show that the community is already flexible concerning Q&A with that degree of effort/interest.

The problem with voting "Yes" here is not that this kind of Q&A won't be allowed (it already is in some special cases), but that it turns routine closures of all sorts of silly stuff into a bigger battle. Do we really want a flood of code-golf here?

  • Re: opening para, how long to we leave something open to allow a sufficiently interesting answer to appear? This seems like a bit of a departure from general policy, where questions are generally evaluated on merit and without reference to the answers.
    – Paul White Mod
    Commented Sep 5, 2017 at 13:41
  • 1
    But I agree wholeheartedly about not wanting SQL code golf here!
    – Paul White Mod
    Commented Sep 5, 2017 at 13:47
  • That's a tension intrinsic in the whole 'sifting for pearls' effort, isn't it? Commented Sep 5, 2017 at 13:58
  • I'm not so sure it is. Sand vs pearls talks about there being an inexhaustible supply of questions - whereas we are looking for great answers. Of course a poor question might lead to a great answer, but more often they come with good (enough) questions. I'm personally of the view that it is OK if we miss the occasional pearl by being rather ruthless with questions.
    – Paul White Mod
    Commented Sep 5, 2017 at 14:11
  • "No, it’s just a mundane grain of sand question that could have been asked by anyone at any time. What makes it remarkable is the incredible answer on that question by Larian LeQuella with over 100 upvotes." — but no-one knew that answer was coming when they were weighing whether to close the question. It's good to keep the bad question count down by closing rubbish early (which is exactly why I don't think we should rush to open a new floodgate), but answers to reveal whether a question is worth keeping sometimes Commented Sep 5, 2017 at 14:48
  • Right, and if the question had been closed, who's to say the answerer wouldn't have written an equally super answer somewhere else, or even self-answered their own (better written) question.
    – Paul White Mod
    Commented Sep 5, 2017 at 17:36
  • By "code golf" do you mean writing a query such that it has a low count of characters? That wasn't what I had in mind at all. I don't see why allowing one class of question implies the other. Also, where would this flood of code golf questions come from? Who wants to ask them? There's exactly one question with a tag of "sql" on the code golf stack exchange.
    – Joe Obbish
    Commented Sep 6, 2017 at 5:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .