Hi,
Hope someone can help with a problem I'm having with building a query in oracle.
I'm a newbie to oracle, allthough i do have some little knowledge of sql -
It's a cinema booking system scenario - and Im trying to get the sql below to output one line, which is a total of the tickets sold for a particular performance in a particular cinema. I have got as far as below, allthough it lists all 12 occurances, when I want it to say 12 tickets sold etc.
I built this up initally in query builder, then added the count and group by manualy.
Any thoughts greatly appreciated as to how i could achieve this, or where i may be going wrong.
Thanks for looking.
select count(ticket.ticket_id) as tickets_sold, "PERFORMANCE"."PERFORMANCE_DATE" as "PERFORMANCE_DATE",
"FILM"."FILM_TITLE" as "FILM_TITLE",
"TICKET"."TICKET_ID" as "TICKET_ID",
"CINEMA"."LOCATION" as "LOCATION",
"PERFORMANCE"."PERFORMANCE_TIME" as "PERFORMANCE_TIME"
from "TICKET" "TICKET",
"RESERVATION" "RESERVATION",
"PERFORMANCE" "PERFORMANCE",
"RUN" "RUN",
"SCREEN" "SCREEN",
"CINEMA" "CINEMA",
"FILM" "FILM"
where "PERFORMANCE"."PERFORMANCE_ID"="RESERVATION"."PERFORMANCE_ID"
and "PERFORMANCE"."RUN_ID"="RUN"."RUN_ID"
and "RUN"."FILM_ID"="FILM"."FILM_ID"
and "RUN"."SCREEN_ID"="SCREEN"."SCREEN_ID"
and "SCREEN"."CINEMA_ID"="CINEMA"."CINEMA_ID"
and "TICKET"."RESERVATION_ID"="RESERVATION"."RESERVATION_ID"
and "PERFORMANCE"."PERFORMANCE_DATE" ='1-mar-09'
and "FILM"."FILM_TITLE" ='PIRATES OF THE CARIBBEAN - AT WORLDS END'
and "CINEMA"."LOCATION" ='bradfordeast'
and "PERFORMANCE"."PERFORMANCE_TIME" ='20:00' group by reservation.performance_id, performance.performance_date, film.film_title, ticket.ticket_id,cinema.location, performance.performance_time order by tickets_sold DESC;
output:
TICKETS_SOLD PERFORMANCE_DATE FILM_TITLE TICKET_ID LOCATION PERFORMANCE_TIME
1 01-MAR-09 PIRATES OF THE CARIBBEAN - AT WORLDS END 485 bradfordeast 20:00
1 01-MAR-09 PIRATES OF THE CARIBBEAN - AT WORLDS END 488 bradfordeast 20:00
1 01-MAR-09 PIRATES OF THE CARIBBEAN - AT WORLDS END 484 bradfordeast 20:00
1 01-MAR-09 PIRATES OF THE CARIBBEAN - AT WORLDS END 491 bradfordeast 20:00
1 01-MAR-09 PIRATES OF THE CARIBBEAN - AT WORLDS END 493 bradfordeast 20:00
1 01-MAR-09 PIRATES OF THE CARIBBEAN - AT WORLDS END 495 bradfordeast 20:00
1 01-MAR-09 PIRATES OF THE CARIBBEAN - AT WORLDS END 489 bradfordeast 20:00
1 01-MAR-09 PIRATES OF THE CARIBBEAN - AT WORLDS END 487 bradfordeast 20:00
1 01-MAR-09 PIRATES OF THE CARIBBEAN - AT WORLDS END 490 bradfordeast 20:00
1 01-MAR-09 PIRATES OF THE CARIBBEAN - AT WORLDS END 492 bradfordeast 20:00
1 01-MAR-09 PIRATES OF THE CARIBBEAN - AT WORLDS END 494 bradfordeast 20:00
1 01-MAR-09 PIRATES OF THE CARIBBEAN - AT WORLDS END 486 bradfordeast 20:00