日期比较 SQL

comparison in dates SQL

我正在处理一个数据集,我必须在其中比较一天的收入与上周同一天的收入。

我已经分享了数据的示例:

Date    DAY_IN_WEEK_NAME    onnetMins
9/18/2015   FRIDAY  311,980,365.00
9/25/2015   FRIDAY  361,232,362.00
9/21/2015   MONDAY  299,167,025.50
9/28/2015   MONDAY  292,725,603.00
9/19/2015   SATURDAY    310,260,553.00
9/26/2015   SATURDAY    314,627,373.50

为了 SQL 写作,我尝试了如下查询:

sel
 (case when day_in_week_name = 'Friday' then  
 (distinct (onnetMins)- distinct (onnetMins)) end) 
 from MYTABLE group by 1

但是,它不起作用。

任何人都可以尝试调整这个 sql 吗?

此查询可能对您有帮助:

SELECT
    t1.DAY_IN_WEEK_NAME
    , t2.onnetMins - t1.onnetMins   
FROM
    MYTABLE t1
    INNER JOIN MYTABLE t2
    ON t1.DAY_IN_WEEK_NAME = t2.DAY_IN_WEEK_NAME
WHERE
    t1.date < t2.date