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

How to query 2 years from 1 field into a single record?

Status
Not open for further replies.

Aximboy

Technical User
Aug 3, 2003
63
US
I have a table with CustomerName, YearSampled, and TestResult fields.
How do I create a query that shows 2009 vs 2010 TestResults per Customer?
I am planning to create a report that shows 3 columns, CustomerName, 2009 TestResult & 2010 TestResult.

Thank you in advance.
 
A self-join might be the best way to that.
Code:
Select a.CustomerName, a.TestResults as 2009Res, b.TestResults as 2010Res from
yourtable a
inner join yourtable b on b.CustomerName = a.CustomerName

where a.yearsampled = '2009' and b.yearsampled = '2010'

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top