! -我不是在寻找可以完成这项工作的付费软件(因为价格太贵)
我们在现金管理方面存在一个问题,以匹配值。
我有两个SQL表,我们将其称为 SHOP_CASH 和 BANK_CASH
1)匹配应基于ShopName-CashAmount-Date进行。
2)在这里我遇到了两个问题
现金应四舍五入至最接近的£50,理想情况下,12400和12499应四舍五入至12450,或者这 IDEAL 是基于现金差额的匹配项小于50,干燥以匹配不同的值,如果差异小于50,则将它们匹配,但这是如何将值匹配起来的问题。这只是愚蠢的想法))???嗯...卡住了。
日期,该商店可以在几天后兑现,因此需要根据兑现日期(例如2018-10-26)和银行日期为RANGE 2018-10-26加入(+7)天)2018-11-02
目前,我不了解这种情况下匹配的可能方式(逻辑)。计算/连接的任何逻辑路径都将受到高度赞赏
尝试: 假设我可以按SHOPNAME联接两个表-酷 然后,我将尝试按日期加入,可能是:
SELECT * FROM SHOP_CASH AS SC
LEFT JOIN BANK_CASH AS BC
ON SC.SHOP_NAME_SC = BC.SHOP_NAME_BC
AND SC.DATE_SC = (ANY DATE FROM SC.DATE_SC TO SC.DATE_SC (+7 DAYS) = TO DATE_BC - not sure how)
AND FLOOR(SC.CASH_SC / 50) * 50 = FLOOR(BC_CASH_BC / 50) * 50
PS 。为此项目将使用Google Big Query。
这是我的(临时解决方案)
WITH MAIN AS(SELECT
CMS.Store_name AS STORE_NAME,
CMS.Date AS SHOP_DATE,
CMB.ENTRY_DATE AS BANK_DATE,
SUM(CMS.Cash) AS STORE_CASH,
SUM(CMB.AMOUNT) AS BANK_CASH
FROM `store_data` CMS
LEFT JOIN `bank_data` AS CMB
ON CMS.store_name = CMB.STRAIGHT_LOOKUP
AND FLOOR(CMS.Cash / 50) * 50 = FLOOR(CMB.AMOUNT / 50) * 50
AND CAST(FORMAT_DATE("%F",CMB.ENTRY_DATE) AS STRING) > CAST(FORMAT_DATE("%F",CMS.Date) AS STRING)
AND CAST(FORMAT_DATE("%F",CMB.ENTRY_DATE) AS STRING) <= CAST(FORMAT_DATE("%F",DATE_ADD(CMS.Date, INTERVAL 4 day)) AS STRING)
GROUP BY STORE_NAME,SHOP_DATE,BANK_DATE)
SELECT
MAIN2.*
FROM (
SELECT
ARRAY_AGG(MAIN ORDER BY MAIN.SHOP_DATE ASC LIMIT 1)[OFFSET(0)] AS MAIN2
FROM
MAIN AS MAIN
GROUP BY MAIN.SHOP_DATE, MAIN.STORE_CASH)
答案 0 :(得分:1)
这是一个非常有趣的案例。
您尚未提供任何示例数据,因此我无法对其进行测试,但这可能有用。由于不确定日期格式,可能需要进行一些修改。让我知道是否有问题。
//////
after_if:
sw $t0 , 12($sp) # i ( stored after modification)
#end of while_main loop
#recursive #1
r1:
blez $t1 , r2
add $a0 , $t1, 1 # n = j+1
jal quick_sort
#recursive #2
r2:
lw $a0 , 4($sp) # n (restored)
lw $t0 , 12($sp) # i (restored)
add $t7 , $a0 , -1 # n-1
bge $t0 , $t7 , done
sll $s2 , $t0 , 2 # i * 4
add $a1 , $a1 , $s2 # &array + (i*4) (address of the ith value)
sub $a0 ,$a0 , $t0 # n = n-i
jal quick_sort
//////