Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 12th, 2006, 04:14 AM
Registered User
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default Joining 3 Queries.

I have three queries :
Query1 :Returns : Empid,LName,FName,Year_1Salary.
Query2 :Returns : Empid,LName,FName,Year_2Salary.
Query3 :Returns : Empid,LName,FName,Year_3Salary.

I want final query which returns as:

QueryFinal :Returns : Empid,LName,FName,Year_1Salary,Year_2Salary, Year_3Salary.

I m working on MS Access database.
Tried Union of all three but dosen'gt give desire result any idea?

Thanks in advance.

Rupen Anjaria.:)
We CAN'T avoid problems, but can solve it.
Old May 11th, 2006, 11:35 AM
j-d j-d is offline
Registered User
Join Date: May 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

use case!
for example:

select name,
case year when 1 then YearSalary else 0 end
case year when 2 then YearSalary else 0 end
case year when 3 then YearSalary else 0 end
select name, year, YearSalary
from tableX
group by year
) t

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem while joining two queries yogeshyl SQL Language 0 July 21st, 2008 04:08 AM
joining tables pit_bait SQL Language 2 September 28th, 2007 07:29 AM
Joining 2 variables together for one name Lucy Classic ASP Basics 1 June 13th, 2006 10:01 AM
Combining Queries or results from 2 queries Ford SQL Server 2000 24 November 7th, 2005 08:54 PM
Joining two tables rajustha SQL Server 2000 1 December 7th, 2003 07:38 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.