sql server programming:
[quoted text, click to view] >> I have received some help from Wayne Snyder on this join .. <<
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.
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
[quoted text, click to view] >>> I have received some help from Wayne Snyder on this join .. << > > 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.
Sure, but what is DDL and how do I do that? regards Henry
[quoted text, click to view] Henry wrote: >>>> I have received some help from Wayne Snyder on this join .. << >> 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. > > Sure, but what is DDL and how do I do that? > > regards > Henry > >
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
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] "Tracy McKibben" <tracy@realsqlguy.com> wrote in message news:eK903ESmGHA.3600@TK2MSFTNGP02.phx.gbl... > Henry wrote: >>>>> I have received some help from Wayne Snyder on this join .. << >>> 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. >> >> Sure, but what is DDL and how do I do that? >> >> regards >> Henry > > 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 > query that you want to join with.
Don't see what you're looking for? Try a search.
|