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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Probelm 1

Status
Not open for further replies.

roropacific

IS-IT--Management
Jun 29, 2002
23
US
I have this query I want to return information just where fiscyr = 2002. However it returns all years.

select r.invtid,r.qty as returns ,i.qty as invoice, r.fiscyr, i.fiscyr as invoice_fiscyr from z_return as r left join z_invoice as i on i.invtid=r.invtid
where r.fiscyr='2002'
group by
r.invtid,i.fiscyr,r.fiscyr,r.qty,i.qty

output

invtid returns invoice fiscyr invoice_fiscyr
BQS-180 7.0 5010.0 2002 2000
BQS-180 7.0 11829.0 2002 2001
BQS-180 7.0 6334.0 2002 2002
BQS-180 7.0 1535.0 2002 2003
 
What do you mean 'it's returning all years'? You asked for the data where r.fiscyr = 2002. Look at the r.fiscyr column, the only date is 2002. That's what you asked for. Are you looking for this?

where r.fiscyr='2002' AND i.fiscyr = '2002'


-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top