汇总从几天到一个月的数据

时间:2018-06-29 18:28:45

标签: sql redash

我有一天提供的数据,我希望将这些数据转换成月度报告。数据看起来像这样。

INVOICE_DATE GROSS_REVENUE NET_REVENUE

2018-06-28,1623.99,659.72

2018-06-27,112414.65,38108.13

2018-06-26,2518.74,1047.14

2018-06-25,475805.92,172193.58

2018-06-22,1151.79,478.96

我该如何创建报告,该报告可以为我提供6月,7月,8月等月的总收入和净收入,而按日报告数据?

到目前为止,这就是我所拥有的

SELECT invoice_date, 
SUM(gross_revenue) AS gross_revenue, 
SUM(net_revenue) AS net_revenue
FROM wc_revenue
GROUP BY invoice_date

2 个答案:

答案 0 :(得分:1)

我只是按年份和月份分组。

SELECT invoice_date, 
       SUM(gross_revenue) AS gross_revenue, 
       SUM(net_revenue) AS net_revenue 
FROM wc_revenue GROUP BY year(invoice_date), month(invoice_date)

由于我不知道您是否可以访问yearmonth函数,因此另一种解决方案是将日期强制转换为varchar并按最左边的7个字符(年份)进行分组+月)

SELECT left(cast(invoice_date as varchar(50)),7) AS invoice_date, 
       SUM(gross_revenue) AS gross_revenue, 
       SUM(net_revenue) AS net_revenue 
FROM wc_revenue GROUP BY left(cast(invoice_date as varchar(50)),7)

答案 1 :(得分:0)

您可以尝试使用Dim aNodeList As Object, i As Long Set aNodeList = ie.document.querySelectorAll(".account-website-name") For i = 0 To aNodeList.Length -1 Debug.Print aNodeList.Item(i).innerText ' Debug.Print aNodeList(i).innerText ''<== sometimes this syntax instead Next 。下面的示例图:

表格数据:

<util:list id="list1">
    <value>1</value>
<util:list>

<util:list id="list2">
    <value>3</value>
    <value>5</value>
<util:list>

<bean
    class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    <property name="targetObject" ref="list1" />
    <property name="targetMethod" value="addAll" />
    <property name="arguments" ref="list2" />
</bean>