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

Combining Queries- i think!!

Status
Not open for further replies.

frankis

Programmer
Sep 21, 2003
14
GB
I'm trying to do a mail merge but am having trouble getting the info I need.Basically I am trying to run a query that will put the figures for the same grant ref into one line, ie that all items belonging to that grant will placed together.

GrantREf ItemType Yr1 Yr2 Yr3 Total
GG021 Salary 120 100 200 520
GG021 Course 50 50 50 150
Help me please!!
if this is easy i will be so peeved, its given me such a migraine!!
 
what, you mean like:

GG021, salary 120 100 200 520, course 50 50 50 150

I'm assuming both of these come from the same table?

use something like:
SELECT DISTINCT GrantRef, "ItemType - Salary", Yr1... , "ItemType - Course", Yr1...
FROM tblName as t1 JOIN tblName as t2 ON t1.GrantRef = t2.GrantRef

fidling needed...

--------------------
Procrastinate Now!
 
Crowley,
Thanks for that but I need spoonfeeding here, i'm just a newbie!!
 
that is spoonfeeding...

put that into a query, and experiment with the field values you select to see how to view/display the fields.

--------------------
Procrastinate Now!
 
SELECT DISTINCT GrantRef, "ItemType - Salary", Yr1... , "ItemType - Course", Yr1...
FROM tblName as t1 JOIN tblName as t2 ON t1.GrantRef = t2.GrantRef

"ItemType - Salary" What is this meant to do, its acting as an expression and appearing exactly as it is in the SQL
 
yes, it's just to label the y1, y2... fields that are salary or course. If you don't include these fields, then it's difficult to see which y1, y2 relate to which ItemType.

you can display it in various different ways depending on the intended use of the query...

--------------------
Procrastinate Now!
 
SORRY
when i try to run the suggested solution it brings up the same values for Salaries as it does for Consumables..
 
A starting point:
SELECT t1.*, t2.*
FROM tblName AS t1 INNER JOIN tblName AS t2 ON t1.GrantRef = t2.GrantRef
WHERE t1.ItemType = 'Salary' AND t2.ItemType = 'Course'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top