试图获取发票差异
尝试对排名1和2使用cte,但是它们中有一个子查询,无法完成!
第二个查询看起来相同,但是rank = 2。
select *
from (
SELECT i.id, i.subtotal/100 as subtotal, i.created_at, i.paid_at
,RANK() OVER (PARTITION BY i.subscription_id ORDER BY i.created_at DESC) AS Rank
From Invoices i
) as r
where r.rank = 1
order by r.created_at desc;
答案 0 :(得分:0)
按照您所在的路径(使用Package: com.applysolutions.moneyfox
Version Code: 2019099001
Version Name: 5.1.2019099.001
Android: 9
Android Build: PQ2A.190405.003
Manufacturer: Google
Model: Pixel 3
CrashReporter Key: c69e70df-a610-4112-be05-e3869f130474
Date: undefined
Xamarin Exception Stack:
MvvmCross.Exceptions.MvxException: Failed to create setup instance
at MvvmCross.Core.MvxSetupSingleton.CreateSetup () [0x00017] in <5379a95ac98a4680b7bb47f5b716a158>:0
at MvvmCross.Core.MvxSetupSingleton.EnsureSingletonAvailable[TMvxSetupSingleton] () [0x00045] in <5379a95ac98a4680b7bb47f5b716a158>:0
at MvvmCross.Platforms.Android.Core.MvxAndroidSetupSingleton.EnsureSingletonAvailable (Android.Content.Context applicationContext) [0x00000] in <5379a95ac98a4680b7bb47f5b716a158>:0
at MvvmCross.Forms.Platforms.Android.Views.MvxFormsAppCompatActivity.OnCreate (Android.OS.Bundle bundle) [0x00006] in <4ea0c9ab37e14fd8aa188ddf8fa8736e>:0
at MoneyFox.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00052] in <2cfc40e7b7be4d839b84f168044b373f>:0
at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x00011] in <8ac02975c09144d5ae9c10aecc6be0c2>:0
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.9(intptr,intptr,intptr)
--- End of inner exception stack trace ---
MvvmCross.Exceptions.MvxException: Could not find a Setup class for application
at MvvmCross.Core.MvxSetupExtensions.CreateSetup[TSetup] () [0x00019] in <5379a95ac98a4680b7bb47f5b716a158>:0
at MvvmCross.Core.MvxSetup.Instance () [0x00015] in <5379a95ac98a4680b7bb47f5b716a158>:0
at MvvmCross.Core.MvxSetupSingleton.CreateSetup () [0x00000] in <5379a95ac98a4680b7bb47f5b716a158>:0
Thread 2:
0 dalvik.system.VMStack.getThreadStackTrace(VMStack.java:-2)
1 java.lang.Thread.getStackTrace(Thread.java:1538)
2 java.lang.Thread.getAllStackTraces(Thread.java:1588)
3 com.microsoft.appcenter.crashes.Crashes.saveUncaughtException(Crashes.java:943)
4 com.microsoft.appcenter.crashes.WrapperSdkExceptionManager.saveWrapperException(WrapperSdkExceptionManager.java:50)
5 md5a0013181b845adff0c8407b475a96272.MainActivity.n_onCreate(MainActivity.java:-2)
6 md5a0013181b845adff0c8407b475a96272.MainActivity.onCreate(MainActivity.java:30)
7 android.app.Activity.performCreate(Activity.java:7144)
8 android.app.Activity.performCreate(Activity.java:7135)
9 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
10 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2931)
11 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086)
12 android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
13 android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
14 android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
15 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)
16 android.os.Handler.dispatchMessage(Handler.java:106)
17 android.os.Looper.loop(Looper.java:193)
18 android.app.ActivityThread.main(ActivityThread.java:6718)
19 java.lang.reflect.Method.invoke(Method.java:-2)
20 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
21 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Thread 6698:
0 java.lang.Object.wait(Object.java:-2)
1 java.lang.Daemons$ReferenceQueueDaemon.runInternal(Daemons.java:178)
2 java.lang.Daemons$Daemon.run(Daemons.java:103)
3 java.lang.Thread.run(Thread.java:764)
Thread 6699:
0 java.lang.Object.wait(Object.java:-2)
1 java.lang.Object.wait(Object.java:422)
2 java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:188)
3 java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:209)
4 java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:232)
5 java.lang.Daemons$Daemon.run(Daemons.java:103)
6 java.lang.Thread.run(Thread.java:764)
Thread 6700:
0 java.lang.Thread.sleep(Thread.java:-2)
1 java.lang.Thread.sleep(Thread.java:373)
2 java.lang.Thread.sleep(Thread.java:314)
3 java.lang.Daemons$FinalizerWatchdogDaemon.sleepFor(Daemons.java:342)
4 java.lang.Daemons$FinalizerWatchdogDaemon.waitForFinalization(Daemons.java:364)
5 java.lang.Daemons$FinalizerWatchdogDaemon.runInternal(Daemons.java:281)
6 java.lang.Daemons$Daemon.run(Daemons.java:103)
7 java.lang.Thread.run(Thread.java:764)
Thread 6707:
0 android.os.MessageQueue.nativePollOnce(MessageQueue.java:-2)
1 android.os.MessageQueue.next(MessageQueue.java:326)
2 android.os.Looper.loop(Looper.java:160)
3 android.os.HandlerThread.run(HandlerThread.java:65)
Thread 6709:
0 android.os.MessageQueue.nativePollOnce(MessageQueue.java:-2)
1 android.os.MessageQueue.next(MessageQueue.java:326)
2 android.os.Looper.loop(Looper.java:160)
3 android.os.HandlerThread.run(HandlerThread.java:65)
Thread 6710:
0 android.os.MessageQueue.nativePollOnce(MessageQueue.java:-2)
1 android.os.MessageQueue.next(MessageQueue.java:326)
2 android.os.Looper.loop(Looper.java:160)
3 android.os.HandlerThread.run(HandlerThread.java:65)
/ row_number()
),可以使用条件聚合。假设您想要rank()
的差异,那么:
subtotal