I have a question that takes the average difference (average) from 7 days a week for Monday, TUES, etc. Average prices It works fine, but I'm sure how can I tell EGs in the same query that this query is found?
About any ideas ... this is a big number ... not by average.
Any ideas? BTW is from this postgrad ... Thank you
SELECT rooms.name, rooms.id, MAX (case when (Dv from avatiles.bookdate) - EXTRACT (DOW to date '2009- 12-13 ')) = 0 then (availables.price ELSE 0 END) day 1, max (in case when (Aquatrat (DOW from availables.bookdate) - Extract (date' Date 2009-12-13 ')) = 1 day (availables.price) ELSE 0 END) Day 2, Max (in case when (Aquatrates (DOWN from Bookmate) - Extract (Date '200-12-12-13')) = 2 THEN (availables.price ELSE 0 END) Day 3, Max (in case when (Aquatates (Divine) S from availables.bookdate) - Extract (DOW FROM DATE '2009-12-13')) = 3 THEN (availables.price ELSE 0 END) Day 4, Max (Case (Extract (DOW from availables.bookdate) - Extract Date '2009-12-13')) = 4 THEN (availables.price ELSE 0 END) day 5, (availables.price) as the average, amount (sm (availables.price)), maximum ( (Signature (spots) -1) + 1) AS beds from availables INNER availables.room_id = include rooms in rooms.id WHERE availables.room_id = '1780' and beneficial price & gt; Room.id. rooms@name
Here's something that should work Select average (average + trius + wads + thur + fly) as the average (average + trius + wads + thur + fly) in the form of average (average + trips + wads + thur + fly) in the form of average, avgtues as average (mon) as Avgmon Avgtues, avg (weds) avgweds, Avg (thurs) as avgthurs, agv (fri) avgfri, MAX ((sign (spots) -1) + 1) from AS beds (SELECT rooms.name, room. ID, case when EXTRACT (DOW from availables.bookdate) = 1 THEN (availables.price ELSE 0 END) In case when extract (availables.bookdate from DOW) = 2 THEN (availables.price) ELSE 0 end), case when EXTRACT (DOW from availables.bookdate) = 3 THEN (availables.price) ELSE 0END) AS weds As, when EXTRACT (DOW from availables.bookdate) = 4 THEN (availables.price) ELSE 0 end), when extract (DOW from availables.bookdate) = 5 THEN (availables.price) ELSE 0 END ) In the form of fri, spots, rooms.id, rooms.name availables, take advantage of INNER rooms at Ables.room_id = rooms.id WHERE availables.room_id = '1780' and availables.price & gt; 0) Room.ID, Room.Name by Group)
Note I did not test, so typos could happen.
No comments:
Post a Comment