1

これに必要なクエリに圧倒されています..

   DATE        UPSRC         UPDST         DNSRC          DNDST

   2013-07-04  1.021        1.541          0.017          23.65
   2013-07-04  1.561        9.55           4.27           5.65
   2013-07-04  41.0451      7.641          9.67           2.65
   2013-07-03  7.51         3.541          3.47           2.65
   2013-07-03  1.021        1.541          2.67           23.65
   2013-07-03  1.561        9.55           34.47          5.65
   2013-07-02  61.0451      4.641          9.57           7.09
   2013-07-02  7.51         4.541          6.67           9.65
   2013-07-02  1.021        6.541          2.543          23.345
   2013-07-01  1.561        2.55           4.367          1.65
   2013-07-01  43.0451      3.641          9.67           7.65
   2013-07-01  7.51         1.541          6.627          9.65

このクエリを使用して生成されたもの

SELECT *
FROM flows_monthly_summary
        WHERE DATE >= '2013-07-01' 
        AND DATE<='2013-07-04' 
        ORDER BY DATE DESC

ここで、(UPSRC+UPDST) の列の TOTAL を UPSTREAM として取得し、(DNSRC+DNDST) を DOWNSTREAM として取得したいと考えています。

DATE                      UPSTREAM                            DOWNSTREAM
2013-07-04       [TOTAL OF UPSRC+UPDST COLUMNS]    [TOTAL OF DNSRC+DNDST COLUMNS]
2013-07-03       [TOTAL OF UPSRC+UPDST COLUMNS]    [TOTAL OF DNSRC+DNDST COLUMNS]
2013-07-02       [TOTAL OF UPSRC+UPDST COLUMNS]    [TOTAL OF DNSRC+DNDST COLUMNS]
2013-07-01       [TOTAL OF UPSRC+UPDST COLUMNS]    [TOTAL OF DNSRC+DNDST COLUMNS]

これに必要なクエリは何ですか? ありがとう!

4

2 に答える 2

4
SELECT `Date`,Sum(UPSRC+UPDST) as  UPSTREAM ,Sum(DNSRC+DNDST) as DOWNSTREAM
FROM flows_monthly_summary
        WHERE DATE >= '2013-07-01' 
        AND DATE<='2013-07-04' 
group by [Date]
        ORDER BY DATE DESC

Date のようなキーワードを列名として使用しないことをお勧めします。

于 2013-07-29T05:36:03.913 に答える
0
SELECT DATE,
       SUM(UPSRC  +  UPDST) as UpStream,
       SUM(DNSRC  +  DNDST) as Downstream
FROM flows_monthly_summary
WHERE DATE >= '2013-07-01' 
        AND DATE<='2013-07-04'
GROUP BY DATE 
ORDER BY DATE DESC
于 2013-07-29T05:39:39.557 に答える