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.
| Author |
Topic |
|
drpkrupa
Yak Posting Veteran
74 Posts |
Posted - 2010-06-15 : 12:31:20
|
| I have table which has three column. select '1995' as year, cast('Toyota' as varchar(50)) as mke, cast('Carola' as varchar(50)) as modelinto #tmpunion allselect '1995' as year, cast('Toyota' as varchar(50)) as mke, cast('Carola' as varchar(50)) as modelunion allselect '1995' as year, cast('Toyota' as varchar(50)) as mke, cast('Camerry' as varchar(50)) as modelunion allselect '1996' as year, cast('Toyota' as varchar(50)) as mke, cast('Truck' as varchar(50)) as modelunion allselect '1996' as year, cast('Toyota' as varchar(50)) as mke, cast('Truck' as varchar(50)) as modelunion allselect '1996' as year, cast('Honda' as varchar(50)) as mke, cast('Civic' as varchar(50)) as modelI want to write query which give me only following two rows.select '1996' as year, cast('Honda' as varchar(50)) as mke, cast('Civic' as varchar(50)) as modeland select '1996' as year, cast('Toyota' as varchar(50)) as mke, cast('Truck' as varchar(50)) as modelthese are only two model that issued on specific year by specific make.It measn i need all model that only issue by make for that year. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-06-15 : 12:33:43
|
select * from #tmp where year = '1996' No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-06-16 : 02:53:31
|
| If you dont want duplicates, use distinct select distinct * from #tmp where year = '1996'MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|