Get content that was produced there is less than one time with SQL on PostgreSQL

1

I want to recover for the content that was produced there is less than 30 days:

-- veces una personna deu groupo interragi con contenido, 
                SELECT  COUNT (swipe.state),swipe.eclipse_id FROM swipe
          WHERE (swipe.state= 2 OR swipe.state = 3 or swipe.state=5 OR swipe.state =6 or swipe.state=8 or swipe.state=9)
              AND swipe.subscriber_id in %s AND swipe.date >= DATEADD(DAY, -30, GETDATE())
            GROUP BY swipe.subscriber_id,swipe.eclipse_id
              ORDER BY (swipe.subscriber_id) ASC; 

But I answered that:

I am unable to connect to the database
column "day" does not exist
LINE 4: ....subscriber_id in (306) AND swipe.date >= DATEADD(DAY, -30, ...
                                                             ^

42703
ERROR:  column "day" does not exist
LINE 4: ....subscriber_id in (306) AND swipe.date >= DATEADD(DAY, -30, ...
                                                             ^

Traceback (most recent call last):
  File "/home/antoine/Swiper/Eclipse-Stats/querySQLPredictions.py", line 82, in request
    (tuple(self.res.iloc[i]['ids']),))
ProgrammingError: column "day" does not exist
LINE 4: ....subscriber_id in (306) AND swipe.date >= DATEADD(DAY, -30, ...

For the minimal and verifiable example here is a table swipe :

subscriber_id eclipse_id date                       state
161           11270      2017-06-07 14:50:07.595999 2
161           10453      2017-06-07 11:27:31.813999 2
156           10453      2017-06-07 11:26:54.319999 1
161           11269      2016-06-07 11:27:39.276000 3
156           10453      2016-06-05 11:00:06.161999 1
156           10453      2016-06-07 11:28:43.901999 2
    
asked by ThePassenger 02.08.2017 в 17:56
source

1 answer

0

If I follow the labels you defined, the problem would be that you are using a SQL server function in Postgres . Specifically when you do DATEADD(DAY, -30, GETDATE()) , you should do something like this: CURRENT_DATE + INTERVAL '1 day' .

In your example it would be like this: CURRENT_DATE + INTERVAL '30 day'

    
answered by 02.08.2017 в 18:06