all groups > sql server programming > june 2006 >
You're in the

sql server programming

group:

Join another table with an existing join


Re: Join another table with an existing join --CELKO--
6/25/2006 6:14:57 PM
sql server programming:
[quoted text, click to view]

Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, data types, etc. in
your schema are. Sample data is also a good idea, along with clear
specifications. Wayne must have had the advantage of seeing your code
and we would like it also.
Join another table with an existing join Henry
6/25/2006 11:22:19 PM
Hi

I have received some help from Wayne Snyder on this join (thanks Wayne) and
that works excellent, thanks Wayne!

However I need to join a third table "meters" m where I need to "present"
the fields m.unit and m.designation, and I also need a "where clause" m.name
like ar.name (m.name is a substring of ar.name) the join must be on the same
as the where (maybe one of them is not necessary?)


So it's something like
select ar.[name], av.id, m.unit, m.designation
Sum(Case WHEN Datediff(Mi, timedate, getdate()) < 60 THEN av.Val ELSE 0
END) as [Last Hour],
Sum(av.val) as Total
From [Analog register] AR INNER JOIN [analog values] AV
On AR.[ID] = AV.[ID]

something else join here I suppose?

GROUP by ar.[name], av.id


*/// this is the existing join which works fine (except from the missing
data from metes)
NB! Count and av.id is not really needed though.

Select ar.[name], av.id, count(*),
Sum(Case WHEN Datediff(Mi, timedate, getdate()) < 60 THEN av.Val ELSE 0
END) as [Last Hour],
Sum(av.val) as Total
From [Analog register] AR INNER JOIN [analog values] AV
On AR.[ID] = AV.[ID]
GROUP by ar.[name], av.id


Does anyone know how to solve that (partial join thingy)?

regards
Henry

Re: Join another table with an existing join Henry
6/26/2006 12:00:00 AM
[quoted text, click to view]

Sure, but what is DDL and how do I do that?

regards
Henry

Re: Join another table with an existing join Tracy McKibben
6/26/2006 8:05:35 AM
[quoted text, click to view]

DDL is an acronym for "data definition language" - it's the statements
used to create your database schema, i.e. CREATE TABLE, CREATE VIEW, etc...

We need to know the structure of your "meters" table, and the existing
Re: Join another table with an existing join Henry
6/26/2006 4:44:08 PM
Hi Tracy

I have made a second attempt ;o)

Please have a look at "Help for joining tables (2nd try ;o) )" if you like

regards
Henry


[quoted text, click to view]

AddThis Social Bookmark Button