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 |
|
k_cire0426
Yak Posting Veteran
63 Posts |
Posted - 2009-11-27 : 00:23:46
|
| i have these two tablestable1col1 col2 col3 col4 col5 "1" "2" "3" "d" 1/1/2009"4" "5" "6" "d" 1/1/2009table2col1"d"is it possible to have a output like this?output if criteria not agreed on col5col1 col2 col3 col4d null null null output if criteria agreed on col5col1 col2 col3 col4d 1 2 3 d 4 5 6 |
|
|
vikky
Yak Posting Veteran
54 Posts |
Posted - 2009-11-27 : 00:32:19
|
| hi,Please Explain Clearly.Thanks,vikky. |
 |
|
|
k_cire0426
Yak Posting Veteran
63 Posts |
Posted - 2009-11-27 : 00:38:39
|
| I just want to have a query that will have an output shown on my first post..this should be the output of the query if criteria not agreed or not equal on col5col1 col2 col3 col4d null null nullthis should be the output of the query if criteria agreed or not equal on col5col1 col2 col3 col4d 1 2 3d 4 5 6 |
 |
|
|
vikky
Yak Posting Veteran
54 Posts |
Posted - 2009-11-27 : 00:45:00
|
| HI,which column related to criteria.we have to check the col5 (datecolumn) with which one.Thanks,vikky. |
 |
|
|
k_cire0426
Yak Posting Veteran
63 Posts |
Posted - 2009-11-27 : 00:49:44
|
| col5 and table1.col4 = table2.col1 |
 |
|
|
vikky
Yak Posting Veteran
54 Posts |
Posted - 2009-11-27 : 01:17:35
|
| Hi,I think this ur required.declare @tabl table(col1 int,col2 int,col3 int,col4 varchar(1),col5 datetime)insert into @tablselect 1,2,3,'d','1/1/2009'union all select 4,5,6,'d','1/1/2009'declare @tab2 table (col1 varchar(1))insert into @tab2 select 'd'select t2.col1 as criteria, t.col1,col2,col3from @tab2 as t2 left join @tabl as t on t2.col1 = t.col4Thanks,vikky. |
 |
|
|
k_cire0426
Yak Posting Veteran
63 Posts |
Posted - 2009-11-27 : 01:26:21
|
| Hello Vikky, Thank you for your time helping me solving this. :) You got the second scenario. Actually, I was having a problem on first scenario which if you have date criteria equal to '1/1/2009' and you need to show the first output.col1 col2 col3 col4d null null null |
 |
|
|
vikky
Yak Posting Veteran
54 Posts |
Posted - 2009-11-27 : 01:44:13
|
| hi,we are not accept that date or any thing else then we need this condision also in join and col5 <> '1/1/2009'Thanks,vikky. |
 |
|
|
|
|
|
|
|