SQL仓库

  1. 查表中数据个数
sql 复制代码
select count(*) from table_name where condition 
  1. 删除表中数据
sql 复制代码
delete from table_name where condition

3.筛选符合条件数据并且将结果根据条件公式求和

sql 复制代码
SELECT
   sum(case 
   	   when transaction_state ='B' then transaction_amount
   	   when transaction_state ='s' then -transaction_amount 
   end
   )as result
FROM 
    stocktransactiondetail_april 
WHERE 
    stock_symbol ='sz300347' AND (transaction_date ='2024-04-19' or transaction_date ='2024-04-22' or transaction_date ='2024-04-23') AND transaction_amount >1000000;
相关推荐
lsc_blog3 小时前
年终自评别贴提交记录,把技术产出讲成变化
数据库·面试·职场和发展·跳槽·求职招聘
FungLeo6 小时前
成为全栈·基础补充·数据库迁移与事务:数据结构怎样安全演进
mysql·postgresql·sqlite·数据一致性·数据库事务·数据库迁移·成为全栈
Zan11 小时前
SQLite + SQLx 实战:为什么已经发布的数据库迁移文件,绝对不能再修改?
数据库·后端·面试
这个DBA有点耶12 小时前
数据同步的三个工程底线:DDL同步、断点续传、一致性校验——开源CDC的边界与KFS的路径
数据库·dba·代码规范
aiks_yuan13 小时前
MySQL GROUP BY 很慢怎么优化:加了索引反而从 1 秒变 7 秒,Using temporary 该不该消(MySQL 8.2 实测 400 万行)
mysql
SelectDB13 小时前
列式存储为什么适合分析类负载?原理、限制与日志场景应用
数据库
数据库小学妹14 小时前
MySQL大字段治理:行溢出机制、覆盖索引与拆表
数据库·mysql·性能优化
爱吃奥利奥_wen14 小时前
SQL Server 基础语法详解:从建库建表到约束与增删改查
服务器·数据库·oracle
这个DBA有点耶15 小时前
MySQL 8.0不可见索引:删索引怕出事,不删又拖慢写入——中间态怎么用?
数据库·mysql·代码规范