Re: Join statement

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: John (John_at_hotmail.com)
Date: 08/19/04


Date: Wed, 18 Aug 2004 18:34:05 -0700

Thanks, I'll try that.

"Pavel S.Vorontsov" <li_bao_aka_poul@mail.ru> wrote in message
news:1092806234.39481@papirus.ftc.ru...
> Or much easier
> CREATE VIEW VIEW1
> AS
> SELECT T1.Date,
> T1.Name,
> isnull(T2.Value,T1.Value)
> FROM Table1 T1 LEFT OUTER JOIN Table2 T2 ON T1.Date = T2.Date AND
> T1.Name = T2.Name
>
> "Adam Machanic" <amachanic@hotmail._removetoemail_.com> wrote in message
> news:OfcyyiNhEHA.2784@TK2MSFTNGP09.phx.gbl...
>> Okay, that makes more sense...
>>
>> You could try something like:
>>
>> CREATE VIEW VIEW1
>> AS
>> SELECT Table1.Date,
>> Table1.Name,
>> Table1.Value
>> FROM Table1
>> WHERE NOT EXISTS (SELECT *
>> FROM Table2
>> WHERE Table2.Date =
> Table1.Date
>> AND Table2.Name =
>> Table1.Name)
>>
>> UNION ALL
>>
>> SELECT Table2.Date,
>> Table2.Name,
>> Table2.Value
>> FROM Table2
>> GO
>>
>> "John" <John@hotmail.com> wrote in message
>> news:OSmcFYNhEHA.1652@TK2MSFTNGP09.phx.gbl...
>> > Basically, Table1 contains original data and I'm not allowed to change
> it
>> or
>> > to add new row to it. Table2 is for me to change the value of Table1
> with
>> > the same Date and Name. So when I query View1, I'll get data from
>> > Table2
>> > (the one I change the value) and the rest of the data come from Table1.
>> see
>> > below
>> >
>> > Table1:
>> > Date Name Value
>> > 1/1/2004 T1 100
>> > 1/2/2004 T1 90
>> > 1/1/2004 T2 95
>> > 1/2/2004 T2 105
>> >
>> > Table2:
>> > Date Name Value
>> > 1/2/2004 T1 91
>> >
>> > VIEW1:
>> > Date Name Value
>> > 1/1/2004 T1 100
>> > 1/2/2004 T1 91 <- this is from Table2
>> > 1/1/2004 T2 95
>> > 1/2/2004 T2 105
>> >
>> > Thanks,
>> >
>> >
>>
>>
>
>



Relevant Pages

  • Re: Join statement
    ... Okay, that makes more sense... ... CREATE VIEW VIEW1 ... Table1 contains original data and I'm not allowed to change it ...
    (microsoft.public.sqlserver.programming)
  • Re: Join statement
    ... > Okay, that makes more sense... ... > CREATE VIEW VIEW1 ... > UNION ALL ... > FROM Table2 ...
    (microsoft.public.sqlserver.programming)
  • Re: Crystal is hiding results from me
    ... > Can a UNION'ed view get rid of rows? ... say I create a View1 with the following command. ... Instead of UNION, try UNION ALL. ...
    (microsoft.public.vb.crystal)
  • View error on partioning column ???
    ... When I try to update a record from the view I receive an error "UNION ALL view 'VIEW1' is not updatable because a partioning column was not found". ... Pat ...
    (microsoft.public.sqlserver.programming)