|
Posted by ElFroggio on 12/19/06 22:00
msrviking@gmail.com wrote:
> Hello everybody,
>
> After several attempts of writing the query, I had to post my
> requirement in the forum.
>
> Here is what I have, what I need and what I did.
>
> Table A
> Col1 Col2
> 1 Nm1
> 2 Nm2
> 3 Nm3
>
> Table B
> Col1 Col2
> 10 100
> 20 200
>
> Table C
> Col1 (A.Col1) Col2 (B.Col1)
> 1 10
> 2 10
>
> Table D
> Col1 (A.Col1) Col2
> 1 Value1
> 2 Value2
>
>
> I need results based on below criteria,
>
> 1.
> Criteria - B.Col2 = 100
> Resultset
> A.Col1 D.Col1
> 1 Value1
> 2 Value2
>
> 2.
> Criteria - B.Col2 =""
> A.Col1 D.Col1
> 1 Value1
> 2 Value2
> 3 NULL
>
> 3.
> Criteria - B.Col2 =200
> Empty resultset
>
> Here is the query I tried, but looks its not working. Probably there is
> a better way to do this.
see http://www.sqlhacks.com/index.php/Retrieve/Conditional-columns
Navigation:
[Reply to this message]
|