💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# mysql常用工作遇到 ### 统计每个人每年 ``` <pre class="calibre13">``` <span class="token5">SELECT</span> username<span class="token1">,</span> <span class="token5">FROM_UNIXTIME</span><span class="token1">(</span>createtime<span class="token1">)</span><span class="token1">,</span> <span class="token5">SUM</span><span class="token1">(</span> day_price <span class="token1">)</span> <span class="token5">AS</span> price <span class="token5">FROM</span> fa_statistics <span class="token5">GROUP</span> <span class="token5">BY</span> <span class="token5">YEAR</span><span class="token1">(</span><span class="token5">FROM_UNIXTIME</span><span class="token1">(</span>createtime<span class="token1">)</span><span class="token1">)</span><span class="token1">,</span>username ``` ``` ### 表数据 ![](https://img.kancloud.cn/c1/73/c173da7f28ac874a83d8990377a951e4_882x187.png) ### 统计每个人每天 ``` <pre class="calibre13">``` <span class="token5">SELECT</span> username<span class="token1">,</span> createtime<span class="token1">,</span> <span class="token5">SUM</span><span class="token1">(</span> day_price <span class="token1">)</span> <span class="token5">AS</span> price <span class="token5">FROM</span> fa_statistics <span class="token5">GROUP</span> <span class="token5">BY</span> <span class="token5">DAY</span><span class="token1">(</span>createtime<span class="token1">)</span><span class="token1">,</span>username ``` ``` ### 结果 ![](https://img.kancloud.cn/9c/6f/9c6f0842dc4d69570e88d35c83dd16a2_658x142.png)