Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SELECT question

Author  Topic 

OldMySQLUser
Constraint Violating Yak Guru

301 Posts

Posted - 2008-01-25 : 12:23:55
I have two tables (MS SQL 2005)

Table 1
-------

account_number transaction_type date_entered user
34 1 12-12-2007 Bill
65 6 14-12-2007 Wayne

Table 2
-------

transaction_type transaction_description
1 New account
2 Stale account
3 Poor payer
4 Frozen account
5 Lapsed account
6 Premium account

How, please, can I create a SELECT which will give me:

account_number transaction_type date_entered user
65 Premium account 14-12-2007 Wayne

jdaman
Constraint Violating Yak Guru

354 Posts

Posted - 2008-01-25 : 12:38:02
[code]SELECT t1.account_number,
t2.transaction_description AS transaction_type,
t1.date_entered,
t1.user
FROM Table1 t1
JOIN Table2 t2 ON t1.transaction_type = t2.transaction_type[/code]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-01-25 : 22:55:29
also you need to filter on transaction_description

WHERE t2.transaction_description ='Premium account'
Go to Top of Page
   

- Advertisement -