当前位置: 首页 > news >正文

SQL server 同环比计算模板

1、计算 月 年 季度的环比和同比 

计算公式如下:

环比增长率 = (本期数 - 上期数) / |上期数| × 100%
同比增长率 = (本期数 - 同期数) / |同期数| * 100%

--- dbo.ads_erp_finance_gross_profit_actual_invoice_yoy_mom_month-- Insert statements for procedure hereDELETE FROM dbo.ads_erp_finance_gross_profit_actual_invoice_yoy_mom_month WHERE dt = @DateThresholdBEGIN TRY  DECLARE @Sql44 NVARCHAR(MAX) =  N'WITH month_sales AS ( select dt,year,CAST(SUBSTRING(ym, 6, 2) AS INT) AS month, money as month_money from dws_erp_finance_gross_profit_actual_invoice_month where dt = ' + QUOTENAME(CONVERT(NVARCHAR(10), @DateThreshold, 120), '''') + N'), sales AS (  SELECT t3.year,t3.month,t3.month_money AS month_money,t3.same_month_last_year_money,ROW_NUMBER() OVER (PARTITION BY [year], [month] ORDER BY [month_money]) AS rn FROM  (SELECT t1.year,t2.year as last_year,t1.month,t1.month_money,t2.month_money AS same_month_last_year_money FROM month_sales AS t1 LEFT JOIN month_sales AS t2 ON t1.month = t2.month AND t1.year - 1 = t2.year) t3), months AS ( SELECT DISTINCT [year], month FROM sales )  INSERT INTO dbo.ads_erp_finance_gross_profit_actual_invoice_yoy_mom_month ([dt],[ym],[month_money],[previous_month_money],[same_month_last_year_money],[yoy_growth_rate],[mom_growth_rate])select ' + QUOTENAME(CONVERT(NVARCHAR(10), @DateThreshold, 120), '''') + N' as dt, CAST(year AS VARCHAR)+ ''-''+  RIGHT(''0'' + CAST(month AS VARCHAR), 2) AS ym,month_money,previous_month_money,same_month_last_year_money,CASE WHEN same_month_last_year_money = 0 THEN null ELSE ((month_money - same_month_last_year_money) / ABS(same_month_last_year_money)) * 100 END AS yoy_growth_rate,CASE WHEN previous_month_money = 0 THEN null ELSE ((month_money - previous_month_money) / ABS(previous_month_money)) * 100 END AS mom_growth_ratefrom ( SELECT DISTINCT q.[year],q.[month],case when s.[month_money] is NULL then 0 else s.[month_money] end AS month_money,    case when sqs.[month_money] is NULL then 0 else sqs.[month_money] end AS same_month_last_year_money,t4.previous_month_money FROM months q  JOIN sales s ON q.[year] = s.[year] AND q.[month] = s.[month] AND s.rn = 1  LEFT JOIN sales sqs ON q.[year] - 1 = sqs.[year] AND q.[month] = sqs.[month] AND sqs.rn = 1left join ( select t2.dt,ym,t2.year,t2.month,t2.month_money,case when monthdiff = 1 then previous_month_money else 0 end  previous_month_moneyfrom(select dt,ym,SUBSTRING(ym, 1, 4) AS year,CAST(SUBSTRING(ym, 6, 2) AS INT) AS month,previous_month,month_money,previous_month_money,DATEDIFF(MONTH, CAST(CAST(previous_month AS VARCHAR) + ''-01'' AS DATE) , CAST(CAST(ym AS VARCHAR) + ''-01'' AS DATE)) monthdifffrom(SELECT t1.dt,t1.year,t1.quarter, t1.ym, CASE WHEN t1_prev.ym IS NULL THEN ''1970-01'' ELSE t1_prev.ym END AS previous_month,CASE WHEN t1_prev.money IS NULL THEN 0 ELSE t1_prev.money END AS previous_month_money,t1.money AS month_money FROM dws_erp_finance_gross_profit_actual_invoice_month t1LEFT JOIN dws_erp_finance_gross_profit_actual_invoice_month t1_prev ON t1.dt = t1_prev.dt AND t1.ym > t1_prev.ymWHERE t1.dt = ' + QUOTENAME(CONVERT(NVARCHAR(10), @DateThreshold, 120), '''') + N' AND NOT EXISTS ( SELECT 1 FROM dws_erp_finance_gross_profit_actual_invoice_month t2 WHERE t2.dt = t1.dt AND t2.ym > t1_prev.ym AND t2.ym < t1.ym )) t1) t2 ) t4 on q.year = t4.year and q.month = t4.month) t1'SET @Sql44 = REPLACE(@Sql44, '@DateThreshold', @DateThreshold)print(@Sql44)EXEC sp_executesql @Sql44END TRY  BEGIN CATCH  DECLARE @ErrorMessage44 NVARCHAR(4000)  SET @ErrorMessage44 = ERROR_MESSAGE()  RAISERROR (@ErrorMessage44, 16, 1)  END CATCH--- dbo.ads_erp_finance_gross_profit_actual_invoice_yoy_pop_quarter-- Insert statements for procedure hereDELETE FROM dbo.ads_erp_finance_gross_profit_actual_invoice_yoy_pop_quarter WHERE dt = @DateThresholdBEGIN TRY  DECLARE @Sql45 NVARCHAR(MAX) =  N'WITH year_quarter_sales AS (SELECT [year] + '' Q''+ [quarter] AS year_quarter,SUM(money) AS quarter_moneyFROM dws_erp_finance_gross_profit_actual_invoice_month WHERE dt = ' + QUOTENAME(CONVERT(NVARCHAR(10), @DateThreshold, 120), '''') + N' GROUP BY [year] + '' Q''+ [quarter]),quarter_sales AS (SELECT [year],[quarter],sum(money) as quarter_money FROM dws_erp_finance_gross_profit_actual_invoice_month where dt = ' + QUOTENAME(CONVERT(NVARCHAR(10), @DateThreshold, 120), '''') + N' group by year, quarter),sales AS ( SELECT  t3.year, t3.quarter,t3.quarter_money AS [quarter_money], t3.same_quarter_last_year_money, ROW_NUMBER() OVER (PARTITION BY [year], [quarter] ORDER BY [quarter_money]) AS rn  FROM  (SELECT t1.year,t2.year as last_year,t1.quarter,t1.quarter_money,t2.quarter_money AS same_quarter_last_year_money FROM quarter_sales as t1 LEFT JOIN quarter_sales as t2 ON t1.quarter = t2.quarter AND t1.year - 1 = t2.year) t3), quarters AS ( SELECT DISTINCT [year], [quarter] FROM sales )INSERT INTO dbo.ads_erp_finance_gross_profit_actual_invoice_yoy_pop_quarter ([dt],[year],[quarter],[quarter_money],[previous_quarter_money],[same_quarter_last_year_money],[yoy_growth_rate],[qoq_growth_rate])select ' + QUOTENAME(CONVERT(NVARCHAR(10), @DateThreshold, 120), '''') + N' as dt,year,quarter,quarter_money,previous_quarter_money,same_quarter_last_year_money,CASE WHEN same_quarter_last_year_money = 0 THEN null ELSE ((quarter_money - same_quarter_last_year_money) / ABS(same_quarter_last_year_money)) * 100 END AS yoy_growth_rate,CASE WHEN previous_quarter_money = 0 THEN null ELSE ((quarter_money - previous_quarter_money) / ABS(previous_quarter_money)) * 100 END AS qoq_growth_ratefrom ( SELECT DISTINCT q.[year],q.[quarter],case when s.[quarter_money] is NULL then 0 else s.[quarter_money] end AS quarter_money,   case when pqs.[previous_quarter_money] is NULL then 0 else pqs.[previous_quarter_money] end AS previous_quarter_money,   case when sqs.[quarter_money] is NULL then 0 else sqs.[quarter_money] end AS same_quarter_last_year_money FROM quarters q  JOIN sales s ON q.[year] = s.[year] AND q.[quarter] = s.[quarter] AND s.rn = 1   LEFT JOIN sales sqs ON q.[year] - 1 = sqs.[year] AND q.[quarter] = sqs.[quarter] AND sqs.rn = 1LEFT JOIN (select t3.dt,t3.year,SUBSTRING(t3.year_quarter, 7, 1) AS quarter,previous_quarter,quarter_money,previous_quarter_moneyfrom (SELECT ' + QUOTENAME(CONVERT(NVARCHAR(10), @DateThreshold, 120), '''') + N' as dt,SUBSTRING(t1.year_quarter, 1, 4) AS year,t1.year_quarter,CASE WHEN t1_prev.year_quarter IS NULL THEN ''1970 Q1'' ELSE t1_prev.year_quarter END AS previous_quarter,t1.quarter_money AS quarter_money,CASE WHEN t1_prev.quarter_money IS NULL THEN 0 ELSE t1_prev.quarter_money END AS previous_quarter_money FROM year_quarter_sales as t1LEFT JOIN year_quarter_sales as t1_prev ON t1.year_quarter > t1_prev.year_quarterWHERE  NOT EXISTS (SELECT 1 FROM year_quarter_sales as t2 WHERE t2.year_quarter > t1_prev.year_quarter AND t2.year_quarter < t1.year_quarter)) t3 ) pqs ON q.[year] = pqs.[year] AND q.[quarter] = pqs.[quarter] ) t1 order by year, quarter asc' SET @Sql45 = REPLACE(@Sql45, '@DateThreshold', @DateThreshold)print(@Sql45)EXEC sp_executesql @Sql45END TRY  BEGIN CATCH  DECLARE @ErrorMessage45 NVARCHAR(4000)  SET @ErrorMessage45 = ERROR_MESSAGE()  RAISERROR (@ErrorMessage45, 16, 1)  END CATCH--- dbo.ads_erp_finance_gross_profit_actual_invoice_yoy_year-- Insert statements for procedure hereBEGIN TRY  DELETE FROM dbo.ads_erp_finance_gross_profit_actual_invoice_yoy_year WHERE dt = @DateThresholdDECLARE @Sql46 NVARCHAR(MAX) =  N'WITH year_sales AS (select year,sum(money) as year_money from dws_erp_finance_gross_profit_actual_invoice_month where dt =' + QUOTENAME(CONVERT(NVARCHAR(10), @DateThreshold, 120), '''') + N' group by year)INSERT INTO dbo.ads_erp_finance_gross_profit_actual_invoice_yoy_year ([dt],[year],[year_money],[previous_year_money],[yoy_growth_rate])select dt,year,year_money,previous_year_money,CASE WHEN previous_year_money = 0 THEN null ELSE ((year_money - previous_year_money) / ABS(previous_year_money)) * 100 END AS yoy_growth_ratefrom (SELECT ' + QUOTENAME(CONVERT(NVARCHAR(10), @DateThreshold, 120), '''') + N' as dt,t1.year,CASE WHEN t1_prev.year IS NULL THEN ''1970'' ELSE t1_prev.year END AS previous_year,t1.year_money AS year_money,CASE WHEN t1_prev.year_money IS NULL THEN 0 ELSE t1_prev.year_money END AS previous_year_money FROM  year_sales as t1LEFT JOIN year_sales as t1_prev ON t1.year > t1_prev.yearWHERE  NOT EXISTS ( SELECT 1 FROM year_sales as t2 WHERE t2.year > t1_prev.year AND t2.year < t1.year)) t2'SET @Sql46 = REPLACE(@Sql46, '@DateThreshold', @DateThreshold)print(@Sql46)EXEC sp_executesql @Sql46	END TRY  BEGIN CATCH  DECLARE @ErrorMessage46 NVARCHAR(4000)  SET @ErrorMessage46 = ERROR_MESSAGE()  RAISERROR (@ErrorMessage46, 16, 1)  END CATCH

2、基础月表:

--- dbo.dws_erp_finance_gross_profit_actual_invoice_month-- Insert statements for procedure hereBEGIN TRY  DELETE FROM dbo.dws_erp_finance_gross_profit_actual_invoice_month WHERE dt = @DateThreshold  INSERT INTO dbo.dws_erp_finance_gross_profit_actual_invoice_month ([dt],[year],[quarter],[ym],actual_invoice_money,sale_cost_money, money)select @DateThreshold as dt, [year],[quarter],[ym], actual_invoice_money,sale_cost_money,actual_invoice_money - sale_cost_money  as moneyfrom (select t1.year,t1.quarter,t1.ym,case when t2.actual_invoice_money is NULL then 0 else t2.actual_invoice_money end as actual_invoice_money,case when t3.sale_cost_money is NULL then 0 else t3.sale_cost_money end as sale_cost_moneyfrom (select dt,year,quarter,ymfrom dim_year_quarter_month where dt = @DateThreshold) t1left join (select year,quarter,ym, money as actual_invoice_money from dws_erp_finance_paybackinvoicesure_month where dt = @DateThreshold) t2on t1.ym = t2.ymleft join (select year,quarter,ym,money as sale_cost_money from dws_erp_finance_cost_month where dt = @DateThreshold) t3on t1.ym = t3.ym) t5DELETE FROM dbo.dws_erp_finance_gross_profit_actual_invoice_month WHERE dt = DATEADD(day, -7, @DateThreshold)print('dws_erp_finance_gross_profit_actual_invoice_month')END TRY  BEGIN CATCH  DECLARE @ErrorMessage37 NVARCHAR(4000)  SET @ErrorMessage37 = ERROR_MESSAGE()  RAISERROR (@ErrorMessage37, 16, 1)  END CATCH 

相关文章:

SQL server 同环比计算模板

1、计算 月 年 季度的环比和同比 计算公式如下&#xff1a; 环比增长率 &#xff08;本期数 - 上期数&#xff09; / |上期数| 100% 同比增长率 &#xff08;本期数 - 同期数&#xff09; / |同期数| * 100% --- dbo.ads_erp_finance_gross_profit_actual_invoice_yoy_m…...

python发送外部请求

在Python中&#xff0c;服务器发送外部请求是一个常见的操作&#xff0c;尤其是在需要集成不同服务或API时。有多种库可以帮助你完成这项任务&#xff0c;但最流行和广泛使用的库之一是requests。以下是如何使用requests库在Python服务器中发送外部请求的基本步骤&#xff1a; …...

c++并发编程面试题

1. C中lock_guard和unique_lock的区别&#xff1f; 在C中&#xff0c;lock_guard和unique_lock都是用于管理互斥锁的类&#xff0c;它们提供了一种 RAII&#xff08;Resource Acquisition Is Initialization&#xff09;机制来确保锁在作用域结束时自动释放。尽管它们的目的相…...

K8S上安装LongHorn(分布式块存储) --use

要在 Kubernetes上安装 LongHorn&#xff0c;您可以按照以下步骤进行操作&#xff1a; 准备工作 参考 官网教程将LongHorn只部署在k8s-worker5节点上。https://github.com/longhorn/longhorn 安装要求 Each node in the Kubernetes cluster where Longhorn is installed must f…...

2024年前端技术发展趋势分析

2024年的前端技术发展趋势继续受到快速变化的技术环境和不断增长的用户期望的影响。以下是2024年前端技术发展的几个关键趋势&#xff1a; 1. Web 组件和自定义元素 Web 组件技术&#xff08;包括 Shadow DOM、HTML Templates 和 Custom Elements&#xff09;正在成为构建可重…...

spring boot 笔记大杂烩

一&#xff0c;springboot项目创建 springboot创建时idea会打开start.spring.io失败报错 可以手动打开这个页面&#xff0c;然后选择maven项目&#xff0c;然后修改group和name名然后添加依赖web&#xff0c;然后生成项目包&#xff0c;解压缩后用idea打开就能用了 运行后报错…...

如何在香港云服务器上优化网站性能?

在香港云服务器上优化网站性能可以通过以下几种方式进行&#xff0c;确保用户从全球各地访问时获得快速、稳定的体验&#xff1a; 1. 使用内容分发网络 (CDN) 优势&#xff1a;CDN可以将静态内容&#xff08;如图像、视频、CSS、JavaScript文件&#xff09;缓存到全球多个节点…...

STM32低功耗与备用备份区域

STM的备份备用区域其实就是两个区块&#xff1a;BKP和RTC。低功耗则其实是STM32四种模式中的三种耗能很低的模式。 目录 一&#xff1a;备用区域 1.BKP 2.RTC 二&#xff1a;低功耗模式 1.睡眠模式&#xff1a; 2.停机模式&#xff1a; 3.待机模式&#xff1a; 一&…...

武汉某汽配公司携手三品软件 共绘PLM项目新蓝图

近日&#xff0c;三品软件与武汉某汽配公司达成战略合作&#xff0c;双方将共同启动PLM项目&#xff0c;以助力该公司在汽车制造业的研发管理领域实现全面升级。 客户简介 该公司自2008年成立以来&#xff0c;一直专注于为汽车制造业提供自动化输送系统、车辆装配的合装技术和…...

uniapp多图上传uni.chooseImage上传照片uni.uploadFile,默认上传9张图

uniapp多图上传uni.chooseImage上传照片uni.uploadFile 代码示例&#xff1a; /**上传照片 多图*/getImage() {uni.chooseImage({count: 9, //默认9sizeType: [original, compressed], //可以指定是原图还是压缩图&#xff0c;默认二者都有sourceType: [album], //从相册选择/…...

MySQL——内置函数

时间函数 select * from msg where date_add(sendtime, interval 2 minute) > now(); 理解&#xff1a; ------------------------------|-----------|-------------|------------------ 初始时间 now() 初始时间2min 字符串 length函数返回字符串长度&#xff0c;以字节为…...

2024年最新版小程序云开发数据模型的开通步骤,支持可视化数据库管理,支持Mysql和NoSql数据库,可以在vue3前端web里调用操作

小程序官方又改版了&#xff0c;搞得石头哥不得不紧急的再新出一版&#xff0c;教大家开通最新版的数据模型。官方既然主推数据模型&#xff0c;那我们就先看看看新版的数据模型到底是什么。 一&#xff0c;什么是数据模型 数据模型是什么 数据模型是一个用于组织和管理数据的…...

智慧水库大坝安全监测预警系统解决方案

前言 水库大坝作为重要的水利设施&#xff0c;承载着防洪涝、灌溉、发电等功能&#xff0c;关系着无数人的生命财产安全&#xff0c;一旦发生意外事故&#xff0c;后果将不堪设想&#xff0c;因此需要建立一套水库大坝安全监测预警系统解决方案。 系统概述 水库大坝安全监测…...

基于SpringBoot+VUE的社区团购系统(源码+文档+部署)

主要内容&#xff1a;Java项目、Python项目、前端项目、PHP、ASP.NET、人工智能与大数据、单片机开发、物联网设计与开发设计、简历模板、学习资料、面试题库、技术互助、就业指导等 业务范围&#xff1a;免费功能设计、开题报告、任务书、中期检查PPT、系统功能实现、代码编写…...

LeetCode 3151. 特殊数组 I【数组】简单【Py3,C++,Java,GO,Rust】

本文属于「征服LeetCode」系列文章之一&#xff0c;这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁&#xff0c;本系列将至少持续到刷完所有无锁题之日为止&#xff1b;由于LeetCode还在不断地创建新题&#xff0c;本系列的终止日期可能是永远。在这一系列刷题文章…...

超级字符串技能:提升你的编码游戏

嘿嘿,uu们,今天咱们来详解字符函数与字符串函数,好啦,废话不多讲,开干&#xff01; 1.:字符分类函数 C语言中又一系列的函数是专门做字符分类的,也就是一个字符属于什么类型的字符的,这些函数的使用需要包含头文件ctype.h 这些函数的使用方法都十分类似,博主在这里就举两到三个…...

米联客-FPGA程序设计Verilog语法入门篇连载-16 Verilog语法_时钟分频设计

软件版本&#xff1a;无 操作系统&#xff1a;WIN10 64bit 硬件平台&#xff1a;适用所有系列FPGA 板卡获取平台&#xff1a;https://milianke.tmall.com/ 登录“米联客”FPGA社区 http://www.uisrc.com 视频课程、答疑解惑&#xff01; 1概述 本小节讲解Verilog语法的时钟…...

【Echarts】custom自定义图表实现甘特图

效果图 主要注意点&#xff1a; 1、右上角图例visualMap实现 2、visualMap增加formatter 3、series使用custom自定义图表&#xff0c;encode解析四维数组。核心是renderItem方法&#xff0c;必填项&#xff0c;且需要注意要全部定义在options里面&#xff01;&#xff01;&…...

【高等代数笔记】003线性方程组的解法(一)

1. 线性方程组的解法 1.1 解线性方程组的矩阵消元法 【例1】解线性方程组 { x 1 3 x 2 x 3 2 3 x 1 4 x 2 2 x 3 9 − x 1 − 5 x 2 4 x 3 10 2 x 1 7 x 2 x 3 1 \left\{\begin{array}{ll} x_{1}3x_{2}x_{3}2 \\ 3x_{1}4x_{2}2x_{3}9 \\ -x_{1}-5x_{2}4x_{3}10 \\…...

Scrapy入门教程

Scrapy入门教程&#xff1a;打造高效爬虫的第一步 1. 引言 在当今的网络世界中&#xff0c;信息是无价的资源。而爬虫工具则是获取这些资源的有力武器。Scrapy 是 Python 生态系统中最强大的爬虫框架之一&#xff0c;它不仅功能强大&#xff0c;而且易于扩展&#xff0c;适用…...

OpenLayers 可视化之热力图

注&#xff1a;当前使用的是 ol 5.3.0 版本&#xff0c;天地图使用的key请到天地图官网申请&#xff0c;并替换为自己的key 热力图&#xff08;Heatmap&#xff09;又叫热点图&#xff0c;是一种通过特殊高亮显示事物密度分布、变化趋势的数据可视化技术。采用颜色的深浅来显示…...

线程与协程

1. 线程与协程 1.1. “函数调用级别”的切换、上下文切换 1. 函数调用级别的切换 “函数调用级别的切换”是指&#xff1a;像函数调用/返回一样轻量地完成任务切换。 举例说明&#xff1a; 当你在程序中写一个函数调用&#xff1a; funcA() 然后 funcA 执行完后返回&…...

前端导出带有合并单元格的列表

// 导出async function exportExcel(fileName "共识调整.xlsx") {// 所有数据const exportData await getAllMainData();// 表头内容let fitstTitleList [];const secondTitleList [];allColumns.value.forEach(column > {if (!column.children) {fitstTitleL…...

新能源汽车智慧充电桩管理方案:新能源充电桩散热问题及消防安全监管方案

随着新能源汽车的快速普及&#xff0c;充电桩作为核心配套设施&#xff0c;其安全性与可靠性备受关注。然而&#xff0c;在高温、高负荷运行环境下&#xff0c;充电桩的散热问题与消防安全隐患日益凸显&#xff0c;成为制约行业发展的关键瓶颈。 如何通过智慧化管理手段优化散…...

【python异步多线程】异步多线程爬虫代码示例

claude生成的python多线程、异步代码示例&#xff0c;模拟20个网页的爬取&#xff0c;每个网页假设要0.5-2秒完成。 代码 Python多线程爬虫教程 核心概念 多线程&#xff1a;允许程序同时执行多个任务&#xff0c;提高IO密集型任务&#xff08;如网络请求&#xff09;的效率…...

IoT/HCIP实验-3/LiteOS操作系统内核实验(任务、内存、信号量、CMSIS..)

文章目录 概述HelloWorld 工程C/C配置编译器主配置Makefile脚本烧录器主配置运行结果程序调用栈 任务管理实验实验结果osal 系统适配层osal_task_create 其他实验实验源码内存管理实验互斥锁实验信号量实验 CMISIS接口实验还是得JlINKCMSIS 简介LiteOS->CMSIS任务间消息交互…...

实现弹窗随键盘上移居中

实现弹窗随键盘上移的核心思路 在Android中&#xff0c;可以通过监听键盘的显示和隐藏事件&#xff0c;动态调整弹窗的位置。关键点在于获取键盘高度&#xff0c;并计算剩余屏幕空间以重新定位弹窗。 // 在Activity或Fragment中设置键盘监听 val rootView findViewById<V…...

今日学习:Spring线程池|并发修改异常|链路丢失|登录续期|VIP过期策略|数值类缓存

文章目录 优雅版线程池ThreadPoolTaskExecutor和ThreadPoolTaskExecutor的装饰器并发修改异常并发修改异常简介实现机制设计原因及意义 使用线程池造成的链路丢失问题线程池导致的链路丢失问题发生原因 常见解决方法更好的解决方法设计精妙之处 登录续期登录续期常见实现方式特…...

iview框架主题色的应用

1.下载 less要使用3.0.0以下的版本 npm install less2.7.3 npm install less-loader4.0.52./src/config/theme.js文件 module.exports {yellow: {theme-color: #FDCE04},blue: {theme-color: #547CE7} }在sass中使用theme配置的颜色主题&#xff0c;无需引入&#xff0c;直接可…...

LRU 缓存机制详解与实现(Java版) + 力扣解决

&#x1f4cc; LRU 缓存机制详解与实现&#xff08;Java版&#xff09; 一、&#x1f4d6; 问题背景 在日常开发中&#xff0c;我们经常会使用 缓存&#xff08;Cache&#xff09; 来提升性能。但由于内存有限&#xff0c;缓存不可能无限增长&#xff0c;于是需要策略决定&am…...