snipt

Ctrl+h for KB shortcuts

SQL

Repeat records in table

1
2
3
4
5
SELECT fields, count(*) as total 
FROM table
WHERE conditions
GROUP By field
HAVING total > 1
https://snipt.net/embed/4383d38f72f5a616a36b755f3e6658e9/
/raw/4383d38f72f5a616a36b755f3e6658e9/
4383d38f72f5a616a36b755f3e6658e9
sql
SQL
5
2019-07-16T12:11:25
True
False
False
Feb 10, 2014 at 05:13 AM
/api/public/snipt/112314/
repeat-records-in-table
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">SELECT</span> <span class="n">fields</span><span class="p">,</span> <span class="k">count</span><span class="p">(</span><span class="o">*</span><span class="p">)</span> <span class="k">as</span> <span class="n">total</span> </span><span id="L-2"><a name="L-2"></a><span class="k">FROM</span> <span class="k">table</span> </span><span id="L-3"><a name="L-3"></a><span class="k">WHERE</span> <span class="n">conditions</span> </span><span id="L-4"><a name="L-4"></a><span class="k">GROUP</span> <span class="k">By</span> <span class="n">field</span> </span><span id="L-5"><a name="L-5"></a><span class="k">HAVING</span> <span class="n">total</span> <span class="o">&gt;</span> <span class="mi">1</span> </span></pre></div> </td></tr></table>
records, repeat, sql

Python

repeating a string in to a list

" ".join(repeat('oo',3))
https://snipt.net/embed/e24eff87700ec4f25efe54ffd4ba88d0/
/raw/e24eff87700ec4f25efe54ffd4ba88d0/
e24eff87700ec4f25efe54ffd4ba88d0
python
Python
1
2019-07-18T11:21:33
True
False
False
/api/public/snipt/6277/
repeating-a-string-in-to-a-list
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">repeat</span><span class="p">(</span><span class="s1">&#39;oo&#39;</span><span class="p">,</span><span class="mi">3</span><span class="p">))</span> </span></pre></div> </td></tr></table>
list, repeat