snipt

Ctrl+h for KB shortcuts

Text only

Get table size

1
2
3
4
5
6
SELECT 
     table_schema as `Database`, 
     table_name AS `Table`, 
     round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` 
FROM information_schema.TABLES 
ORDER BY (data_length + index_length) DESC;
https://snipt.net/embed/43bf75d0b92ac72e6b762eb8579e0c57/
/raw/43bf75d0b92ac72e6b762eb8579e0c57/
43bf75d0b92ac72e6b762eb8579e0c57
text
Text only
6
2024-05-19T14:59:12
True
False
False
/api/public/snipt/65/
get-table-size
<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> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>SELECT </span><span id="L-2"><a name="L-2"></a> table_schema as `Database`, </span><span id="L-3"><a name="L-3"></a> table_name AS `Table`, </span><span id="L-4"><a name="L-4"></a> round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` </span><span id="L-5"><a name="L-5"></a>FROM information_schema.TABLES </span><span id="L-6"><a name="L-6"></a>ORDER BY (data_length + index_length) DESC; </span></pre></div> </td></tr></table>
mysql, mysqli, sql

Text only

Sum of not null values

select count(*) as totalsent, sum(opened is not null) as opened, round((sum(opened is not null)/count(*))*100) openperc, sum(clicked is not null) as clicked, round((sum(clicked is not null)/sum(opened is not null))*100) clickperc
https://snipt.net/embed/3ec2b73c60eba7468418c6d08ad753ee/
/raw/3ec2b73c60eba7468418c6d08ad753ee/
3ec2b73c60eba7468418c6d08ad753ee
text
Text only
2
2024-05-02T15:32:51
True
False
False
Apr 20, 2018 at 01:19 PM
/api/public/snipt/56/
sum-of-not-null-values
<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>select count(*) as totalsent, sum(opened is not null) as opened, round((sum(opened is not null)/count(*))*100) openperc, sum(clicked is not null) as clicked, round((sum(clicked is not null)/sum(opened is not null))*100) clickperc </span></pre></div> </td></tr></table>
mysql, mysqli, sql