Re: select query assistance
- From: "AshleyT" <AshleyT@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 7 Apr 2005 08:05:04 -0700
Perfect! Thanks.
What about if I want only tickets where all ITEMS has Department 2. So they
only bought Cigarettes.
Thanks,
"Hugo Kornelis" wrote:
> On Tue, 5 Apr 2005 12:31:10 -0700, AshleyT wrote:
>
> >Querying a table that has the line items for a ticket sold at a retail store.
> > So I am looking for the tickets that only have CIGARETTE items on it. The
> >ITEM table has columns:
> >
> >TICKET NUM (PK)
> >TICKET_DATE (PK)
> >LINE # (PK)
> >ITEMDESC
> >ITEM UPC
> >ITEM DEPARTMENT (When equal to 2 then cigarette)
> >
> >So I want tickets that ONLY have cigarette items (all items on the tickets
> >are cigarettes no matter the ITEM count.)
> >
> >Thanks for any help.
>
> Hi Ashley,
>
> SELECT (column list goes here)
> FROM YourTable AS a
> WHERE EXISTS (SELECT *
> FROM YourTable AS b
> WHERE b.Ticket_Num = a.Ticket_Num
> AND b.Ticket_Date = a.Ticket_Date
> AND b.Item_Dept = 2)
> (untested)
>
> Best, Hugo
> --
>
> (Remove _NO_ and _SPAM_ to get my e-mail address)
>
.
- Follow-Ups:
- Re: select query assistance
- From: Hugo Kornelis
- Re: select query assistance
- References:
- select query assistance
- From: AshleyT
- Re: select query assistance
- From: Hugo Kornelis
- select query assistance
- Prev by Date: Re: select query assistance
- Next by Date: Re: select query assistance
- Previous by thread: Re: select query assistance
- Next by thread: Re: select query assistance
- Index(es):