Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Needing Help with a sub query

Status
Not open for further replies.

civilwarjunky

IS-IT--Management
Aug 26, 2004
19
0
0
US
I am new to SQL and I need to preform a sub query I think t0 get info I need. The code I am sending is returning all customers that have ever ordered BHM since 4-22-2005. I have verified it and the return is correct. I know need to go one step ruther and I need to now all customers that have ordered before but not this year. Have not ordered between 6-30-2004 and 4-22-2005. can you help. below is big picture.


Select Contact.firstname+','+lastname as 'Name',contactpropertylistitem.name as 'Grade',
Managedbyid as 'TM',Program.name as 'Program',Location.name as 'School',
location.mailingaddress1,location.mailingaddress2,location.mailingcity,
location.mailingstate,location.mailingzip,contact.isactive,
contactpropertylist.name,Orderitem.id,orderitem.createdon,
Programitem.itemcode
from location,contact,District,orderitem,Program,Programitem,contactpropertylist,
contactpropertylistitem,contactproperty
Where Contact.id=orderitem.contactid
and contact.id=contactproperty.contactid
and contactpropertylist.id=contactpropertylistitem.contactpropertylistid
and contactpropertylistitem.id=contactproperty.contactpropertylistitemid
and Location.id= orderitem.locationid
and Program.id=programitem.programid
and Programitem.id=Orderitem.programitemid
and District.id=Location.districtid
and contact.isactive=1
and District.name not like '%HP CA%'
and Program.name='BHM'
and orderitem.shippedon<'2005-04-18'
order by contact.lastname, orderitem.createdon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top