Re: Join statement
From: John (John_at_hotmail.com)
Date: 08/19/04
- Next message: John Kane: "Re: storing and searching office docs in SQL"
- Previous message: Girish: "how to return alphanumeric data only?"
- In reply to: Pavel S.Vorontsov: "Re: Join statement"
- Messages sorted by: [ date ] [ thread ]
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,
>> >
>> >
>>
>>
>
>
- Next message: John Kane: "Re: storing and searching office docs in SQL"
- Previous message: Girish: "how to return alphanumeric data only?"
- In reply to: Pavel S.Vorontsov: "Re: Join statement"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|