SQLBoy之LC刷题函数篇

SQLBoy之LC刷题函数篇

时间篇

 1.时间差值函数
 datediff (date1,date2): res = days of from date1 to date2 
						if date1 > date2 IS positive number
						else IS negative number
Attention : return Interger Not Boolean
e.g. :  datediff("2023-05-02","2023-05-01")  # 1
2.日期 +N / -N函数
addDate(date,INTERVAL expr unit) #expr (time interval):time to add positive number +  /  negative number -
								 #unit  : day、minute、hour、second  default:day
detail from https://blog.csdn.net/weixin_46082526/article/details/108044313
3.计算相差日期
timeStampDiff(unit,date1,date2)Calculate the difference based on units
e.g. :TIMESTAMPDIFF(HOUR, '2023-03-22 07:00:00', '2023-03-22 18:00:00'); # 11

String篇

1、Contact函数的使用
contact(str1,str2,...) multiple strings to one string
e.g. : contact("hello","、","world")   # hello、world
2、group_contact函数的使用
group_concat([distinct] 要连接的字段 [order by 排序字段] [separator '分隔符'])
e.g. : 
INPUT:
Activities 表:
+------------+-------------+
| sell_date  | product     |
+------------+-------------+
| 2020-05-30 | Headphone   |
| 2020-06-01 | Pencil      |
| 2020-06-02 | Mask        |
| 2020-05-30 | Basketball  |
| 2020-06-01 | Bible       |
| 2020-06-02 | Mask        |
| 2020-05-30 | T-Shirt     |
+------------+-------------+
OUTPUT:
+------------+----------+------------------------------+
| sell_date  | num_sold | products                     |
+------------+----------+------------------------------+
| 2020-05-30 | 3        | Basketball,Headphone,T-shirt |
| 2020-06-01 | 2        | Bible,Pencil                 |
| 2020-06-02 | 1        | Mask                         |
+------------+----------+------------------------------+
Answer:
select sell_date,count(distinct product) as num_sold,GROUP_CONCAT(distinct product) products
from Activities 
group by sell_date;
3、left,right函数的使用
left:
format:left(expression,length) 
return leftmost characters of a expression
e.g. : left("hello",2)   # he

right:
format:right(expression,length) 
return rightmost characters of a expression
e.g. : right("hello",3)   # llo
4、lower,upper函数的使用
lower:
format:lower(expression)
Convert all characters to lowercase
e.g. : lower("HeLLo")   # hello
upper:
format:upper(expression)
Convert all characters to uppercase
e.g. : lower("HeLLo")   # HELLO

Over窗口函数

over( [ PARTITION BY column ] [ ORDER BY culumn ] )

The OVER window function must be used together with the aggregate function or sorting function. The aggregate function generally refers to common functions such as SUM(), MAX(), MIN, COUNT(), AVG(), etc. Sort functions generally refer to RANK(), ROW_ NUMBER(),DENSE_ RANK(), NTILE(), etc

row_number()

ROW_NUMBER()
Sort the data found by SELECT, adding a serial number to each piece of data. It cannot be used as a ranking for student grades, as there are duplicates in student grades. Rank() is best for ranking grades

rank()

RANK()
The RANK() function, as the name suggests, can rank a certain field. And row_ The difference between number() is that it will be ranked side by side

dense_rank()

It is also a ranking function, similar to the RANK() function, but it will continue to sort by this sequence number after it ranks side by side, while RANK() will default to skipping those sequence numbers
For example, there are three places in the first place, using dense_rank() of the next person in rank () is 2. And Rank()'s ranking is 4

ratio_to_report()

ratio_to_report() over(partition by … order by …) 求百分率 配合round函数进行优化结果百分比
Ratio_to_report() 括号中就是分子,over() 括号中就是分母。

其他函数

1、空值赋值函数
IFNULL(expression, alt_value) 
if expression is null change to alt_value
e.g. :ifnull(referee_id,0)<>2;  if referee_id is null change referee_id to 0 
2、if函数的使用
if(expr,res1,res2) expr is boolean type. if true return res1 else res2 
expr have exprs use && or || 
e.g. :Can a triangle be formed 
select x,y,z,if(x+y>z && x-y<z && x-z<y && y-z<x,"Yes","No") as triangle  
from Triangle ;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: LC椭圆函数低通滤波器是一种电子电路,用于对信号进行滤波以滤除高频成分,保留低频成分。它由电感(L)和电容(C)组成,形成了一个带有阻抗的电路。该滤波器的特点是具有极窄的带通特性和高阻带特性。 LC椭圆函数低通滤波器的工作原理是利用电感和电容的特性,通过改变电路的阻抗来实现滤波。当输入信号通过电感和电容时,高频成分会受到电路的阻抗影响而被滤除,只有低频成分能够通过,实现滤波效果。 这种滤波器采用了LC的元件,因此具有较为理想的低阻和高阻带特性。通过调整电感和电容的数值,可以达到不同的滤波效果。通常情况下,随着频率的增加,阻带特性逐渐增强,可以实现对高频信号的有效滤除,并保留低频成分。 LC椭圆函数低通滤波器在信号处理和通信系统中广泛应用。它能够滤除噪声和干扰,提高信号的质量和准确性。在音频处理中,可以用于降低噪声和杂音,提高音频的清晰度和音质。在无线通信系统中,可用于滤除频率混叠干扰,提高信号的传输效果。 总的来说,LC椭圆函数低通滤波器是一种有效的滤波器,通过调整电感和电容的参数,能够实现对高频信号的滤除,保留低频信号,提高信号的质量和准确性。 ### 回答2: LC椭圆函数低通滤波器是一种常用的电子滤波器,广泛应用于保护电路中的不同频率信号。它由电感(L)和电容(C)元件组成的串联电路构成。其特点是能够实现较好的陷波特性和阻带衰减,同时具有较小的群延迟。 LC椭圆函数低通滤波器的工作原理是通过串联的电感和电容元件来延迟和衰减高频信号,使其通过滤波器时被削弱或抑制。它具有截止频率和通带范围的设定,只允许低于截止频率范围内的信号通过,高于截止频率的信号则被滤除。 LC椭圆函数低通滤波器采用椭圆函数作为过渡函数,可以提供更高的过渡斜率和更大的阻带衰减。这意味着在截止频率范围内,通过滤波器的信号与目标信号更接近,不会有明显的失真或相位变化。 由于LC椭圆函数低通滤波器可以实现较低的群延迟,因此在需要较高时域分辨率的应用中非常有用。例如,在音频处理中,我们可以使用LC椭圆函数低通滤波器来消除高频噪声,使音频信号更清晰。 总之,LC椭圆函数低通滤波器是一种常用的电子滤波器,通过串联的电感和电容元件来延迟和衰减高频信号,使其通过滤波器时被削弱或抑制。它具有较好的陷波特性、较大的阻带衰减和较小的群延迟,适用于保护电路和音频处理等应用。 ### 回答3: LC椭圆函数低通滤波器是指使用LC电路中的电感和电容元件所构成的滤波器,其主要功能是通过滤除高频信号,保留低频信号。LC椭圆函数低通滤波器是一种非常常见和重要的滤波器,常被用于电子通信和电子仪器等领域。 通过LC椭圆函数低通滤波器可以实现对高频噪声的滤除,使得信号可以更加稳定和可靠地传输。在滤波器中,电感和电容的参数可以根据需要进行调节,以达到不同的滤波效果。 LC椭圆函数低通滤波器的原理是利用电感和电容的特性对频率进行筛选。对于低频信号,其波长较长,通过电感元件时电感对信号起到阻挡的作用,限制了其传输。而对于高频信号,其波长较短,通过电感时电感对信号起到较小的阻碍作用。通过调节电感和电容的数值,可以使滤波器对不同频率的信号起到不同的衰减效果。 LC椭圆函数低通滤波器的性能指标通常包括截止频率、衰减比等。截止频率是指滤波器开始对信号进行衰减的频率,衰减比则是用来衡量滤波器对高频信号的降噪能力的指标。 总之,LC椭圆函数低通滤波器是一种可以对高频信号进行滤除的滤波器,在电子通信和电子仪器等领域应用广泛,通过调节电感和电容的参数,可以实现不同频率信号的滤波效果。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值