0

I am attempting a SQL query and getting this error:

ERROR: syntax error at or near "rental_date"
LINE 4: select I.store_id,EXTRACT(MONTH FROM TIMESTAMP rental_date) ...

This is my code:

select 
    store_id, Month_Name, max(RentOrder) as maximum_order 
from 
    (select 
         I.store_id, EXTRACT(MONTH FROM TIMESTAMP rental_date) as Month_Name,
         count(rental_id) as RentOrder 
     from 
         Rental R 
     inner join 
         Inventory I on R.inventory_id = I.inventory_id 
     group by 
         I.store_id, EXTRACT(MONTH FROM TIMESTAMP rental_date) ) as T 
group by 
    store_id, Month_Name

I have checked the names of the variables thoroughly matching my database.

However, it is still throwing the syntax issue. Assistance would be appreciated to solve this!

2 Answers 2

1

i just remove timestam from your query A and rest of the things are fine

 select 
        store_id, Month_Name, max(RentOrder) as maximum_order 
    from 
        (select 
             I.store_id, EXTRACT(MONTH FROM rental_date) as Month_Name,
             count(rental_id) as RentOrder 
         from 
             Rental R 
         inner join 
             Inventory I on R.inventory_id = I.inventory_id 
         group by 
             I.store_id, EXTRACT(MONTH FROM rental_date) ) as T 
    group by 
        store_id, Month_Name
Sign up to request clarification or add additional context in comments.

Comments

0

I assume rental_date already is a timestamp. Remove the TIMESTAMP in the EXTRACT() calls.

...
EXTRACT(MONTH FROM rental_date)
...

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.