Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 12th, 2006, 04:14 AM
Registered User
Points: 1,897, Level: 17
Points: 1,897, Level: 17 Points: 1,897, Level: 17 Points: 1,897, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: Mumbai, Maharastra, India.
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.
Reply With Quote
  #2 (permalink)  
Old May 11th, 2006, 11:35 AM
j-d j-d is offline
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
from
(
select name, year, YearSalary
from tableX
group by year
) t

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 02:08 AM.


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