Re: Help with a COUNT / SELECT query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



SELECT COUNT(WMS_Area.Area_ID) AS complete_areas FROM WMS_Area, WMS_Bookings 
WHERE WMS_Area.Area_ID = WMS_Bookings.Area_ID
AND MIN(WMS_Bookings.Booking_Status) = 2
GROUP BY WMS_Area.Area_ID


Or something like that.. there's probably a better way to do it.. 


On Fri January 23 2004 1:05 pm, Shaun wrote:
> Thanks for your reply,
>
> but that only tells me how many complete Bookings there are. I need to know
> how many Areas are complete i.e. for each Area where Bookings take place,
> all of those Bookings have been completed.
>
> Any ideas?
>
> "Oòv?n?Oòsis" <martin@xxxxxxxxxxxxxxx> wrote in message
> news:1074891125.4011897544054@xxxxxxxxxxxxxxxxxx
>
> > Mensaje citado por Shaun <shaun@xxxxxxxxxxxxxx>:
> > > Hi,
> > >
> > > I have a Bookings application. When a Booking is made it is entered in
>
> to
>
> > > the Bookings table. Bookings take place at Areas, held in the Areas
>
> table.
>
> > > Each Area has a unique Area_ID held in the Bookings table for each
>
> Booking.
>
> > > Each Booking needs to be completed and when done so the Booking_Status
>
> for
>
> > > each Booking is updated to '2'. An Area is complete when all Bookings
> > > at that
> > > Area have been completed. How can I run a query that tells me how many
> > > completed Areas there are in the system?
> >
> > SELECT count(*) FROM WMS_Bookings WHERE Booking_Status = 2;
> >
> > Saludos... :-)
> >
> > > Thanks for your help
> > >
> > > CREATE TABLE WMS_Bookings (
> > >   Booking_ID int(11)  DEFAULT '' NOT NULL auto_increment,
> > >   User_ID int(11)  DEFAULT '0' NOT NULL ,
> > >   Project_ID int(11)  DEFAULT '0' NOT NULL ,
> > >   Area_ID int(11)  DEFAULT '0' NOT NULL ,
> > >   Booking_Start_Date datetime  DEFAULT '0000-00-00 00:00:00' NOT NULL ,
> > >   Booking_End_Date datetime  DEFAULT '0000-00-00 00:00:00' NOT NULL ,
> > >   Booking_Completion_Date date    ,
> > >   Booking_Status int(2)  DEFAULT '0' NOT NULL ,
> > >   Additional_Notes text    ,
> > >   PRIMARY KEY (Booking_ID)
> > > );
> > >
> > > CREATE TABLE WMS_Area (
> > >   Area_ID int(11)  DEFAULT '' NOT NULL auto_increment,
> > >   Area_Name varchar(40)  DEFAULT '' NOT NULL ,
> > >   Area_Address varchar(255)  DEFAULT '' NOT NULL ,
> > >   Area_Postcode varchar(10)  DEFAULT '' NOT NULL ,
> > >   Area_Telephone varchar(15)  DEFAULT '' NOT NULL ,
> > >   PRIMARY KEY (Area_ID)
> > > );
> > >
> > > --
> > > PHP Database Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> > --
> > select 'mmarques' || '@' || 'unl.edu.ar' AS email;
> > -------------------------------------------------------
> > Martín Marqués          |   Programador, DBA
> > Centro de Telemática |     Administrador
> >                Universidad Nacional
> >                     del Litoral
> > -------------------------------------------------------

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux