Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7705825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:57:32+00:00 2026-05-31T23:57:32+00:00

Given the following tables: shows: title | basic_ticket_price —————-+——————– Inception | $3.50 Romeo &

  • 0

Given the following tables:

 shows:

      title      | basic_ticket_price
 ----------------+--------------------
  Inception      |              $3.50
  Romeo & Juliet |              $2.00

performance:

  perf_date  | perf_time |     title
 ------------+-----------+----------------
  2012-08-14 | 00:08:00  | Inception
  2012-08-12 | 00:12:00  | Romeo & Juliet

booking:
  ticket_no | perf_date  | perf_time | row_no | person_id
 -----------+------------+-----------+--------+-----------
          1 | 2012-08-14 | 00:08:00  | P01    | 1
          2 | 2012-08-12 | 00:12:00  | O05    | 4
          3 | 2012-08-12 | 00:12:00  | A01    | 2

And an additional table: seat which contains a list of seats numbered like that of row_no in booking with an area name.

Having grouped the booked seats using this statement:

select count(row_no) AS row_no,
       area_name 
from seat 
where exists (select row_no 
              from   booking 
              where booking.row_no = seat.row_no) 
group by area_name;

which produces:

    row_no |  area_name
   --------+--------------
         1 | rear stalls
         2 | front stalls

How can I now use the counted rows and area_name to write a single SQL statement to produce a list showing the names of shows, dates and times of performances, and the number of booked seats in each area?

I’ve tried this:

 select s.title,
        perf_date,
        perf_time,
        count(row_no) AS row_no,
        area_name 
 from shows s, 
      performance,
      seat 
 where exists (select row_no 
               from booking 
               where booking.row_no =  seat.row_no) 
 group by area_name,s.title,performance.perf_date,performance.perf_time;

But it shows repeated rows:

      title      | perf_date  | perf_time | row_no |  area_name
 ----------------+------------+-----------+--------+--------------
  Romeo & Juliet | 2012-08-12 | 00:12:00  |      1 | rear stalls
  Romeo & Juliet | 2012-08-14 | 00:08:00  |      2 | front stalls
  Inception      | 2012-08-12 | 00:12:00  |      1 | rear stalls
  Inception      | 2012-08-14 | 00:08:00  |      2 | front stalls
  Inception      | 2012-08-14 | 00:08:00  |      1 | rear stalls
  Inception      | 2012-08-12 | 00:12:00  |      2 | front stalls
  Romeo & Juliet | 2012-08-14 | 00:08:00  |      1 | rear stalls
  Romeo & Juliet | 2012-08-12 | 00:12:00  |      2 | front stalls
  (8 rows)

Any help with solving this would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:57:33+00:00Added an answer on May 31, 2026 at 11:57 pm

    On a per performance entry, find all bookings. Of those bookings, link to the seats table to determine the area name. Then, simple COUNT(*) grouped by the criteria per show / area.

    SELECT
          p.perf_date,
          p.perf_time,
          p.title,
          s.area_name,
          COUNT(*) as SeatsSold
       from
          performance p
    
             JOIN booking b
                ON p.perf_date = b.perf_date
                AND p.perf_time = b.perf_time
    
                JOIN seat s
                   ON b.row_no = s.row_no
       group by
          p.perf_date,
          p.perf_time,
          p.title,
          s.area_name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following Html.ActionLink: @Html.ActionLink(Model.dsResults.Tables[0].Rows[i][title].ToString(), ItemLinkClick, new { itemListID = @Model.dsResults.Tables[0].Rows[i][ItemListID], itemPosNum = i+1
Given the following tables: Topic id, last_updated_child_id Response id, topic_id, updated_at How do I
Given the following Tables: Names Id int Name varchar Properties Id int NameId varchar
Problem Given the following two tables, I'd like to select all Ids for Posts
Given the following html table and script shown below I am having a problem
Given the following table PAYMENT_Date TRANSACTION_TYPE PAYMENT_AMT 1/1/2012 P 184366 1/1/2012 R -5841 1/2/2012
Given the follwing: SQL Tables: Names ----- Id (int) FirstName (varchar) LastName (varchar) NameProperties
Given the following data/schema: DECLARE @t1 TABLE ( Id int NOT NULL ) DECLARE
Given a table of the following form CustumerID | Amount ------------------- 1 | 100
Given a simple table with the following data: id | result | played ----+--------+------------

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.