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

Need help creating a query

Status
Not open for further replies.

sjh

Programmer
Oct 29, 2001
263
US
Hi,
I need help with writing a query. I have three tables as listed below.

tblProjects
proj_id

tblBudgets
budget_id

tblProject_Budget
proj_id
budget_id
value

In my report, I would like to display the data like this:
Project ID Budget for budget_id=1 Budget for budget_id=2
--------------------------------------------------------------------------------------------------
tblProjects.proj_id tblProject_Budget.value tblProject_Budget.value

I have trouble coming up with a query that will return the data in the above format. Please help!

Thank you!
SJH
 
Hi,
Code:
Select PB.ProjectID, PB.Value as [Budget for budget_id=1], '' As [Budget for budget_id=2]
From tblProject_Budget As PB
Where PB.budget_id=1
UNION
Select PB.ProjectID, '', PB.Value
From tblProject_Budget As PB
Where PB.budget_id=2


Skip,

[glasses] [red]Be advised:[/red] When transmitting sheet music...
If it ain't baroque, don't fax it! [tongue]
 
SJH,
Have you considered a crosstab query?

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top