如何按日期和交易ID对计算进行排序? [英] How to sort calcuation by date and transaction id?

查看:97
本文介绍了如何按日期和交易ID对计算进行排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对使用 If,Else 反对计算股票的声明感到困惑。按日期排序相同。


在相同日期之间计算运行总计真的有挑战:


我的表架构是:

I have Confusion against utilize If,Else Statement against calculation of stock By date. And sort the same by date.

There is real challenge to calculate running total between equal date:


My Table Schema Is:

展开 | 选择 | Wrap | 行号

推荐答案

SQL实际上并不是这样做的地方,它应该是一个函数前端应用程序或报告。


您可以通过游标执行此操作,或者您可以使用相关子查询通过对所有行的列求和来计算当前余额日期小于或等于cur租赁日期。请注意,如果您要查看多行,这可能会非常慢。


这样的事情(我称之为表格库存,因为您没有提供名称)
SQL is not really the place to do this, it should be a function of the front end application, or report.

You could do it by a cursor, or you could use a correlated sub query to calculate the current balance by summing the columns for all rows where the date is less than or equal to the current date. Note that this can be very slow when you have more than a few rows to look at

Something like this (Ive called the table stocktable as you didnt supply a name)
展开 | 选择 | Wrap | 行号


你好,

gpl


首先你必须在你的陈述中使用 COALESCE ISNULL 函数来计算任何可以为空的。


并最后检查你的陈述的结果这是不正确的或不按升序日期计算。

gpl

First of all you have to use COALESCE and ISNULL function in your statement which will count any nullable.

and finally check the result of your statement which is not correct or not calculated by Ascending date.


@mah eshwag


看起来您发布了将gpl的代码桥接到您的解决方案(COALESCE和ISNULL)的函数。

这个问题的答案是什么?

最终解决方案的脚本是什么?
@maheshwag

It looks like you posted the functions to bridge gpl''s code to your solution(COALESCE and ISNULL).
Is this question answered?
What was the script for your final solution?


这篇关于如何按日期和交易ID对计算进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆