?
Solved

select where one attribute has another

Posted on 2007-12-06
4
Medium Priority
?
211 Views
Last Modified: 2012-05-05
this is a weird one, maybe.  i'm in the process writing the procedure below 3 different ways

1., give me the stats on each endpoint, all clients
2., give me the stats on each client, all endpoints
3., give me the stats on each endpoint/client pair  (this is the one posted below)

select b.EndPoint,b.Client,min(a.latency) AS MIN, max(a.latency) AS MAX, AVG(a.latency) AS AVG, stdev(a.latency) AS StDEV
FROM tableA a inner join tableBp b WITH (NOLOCK)
ON a.orderno = b.orderno
GROUP BY endpoint,client

unfortunately, in some cases, there are orderno's without endpoint and/or clients.  what is the most appropriate way to restrict my dataset to only those orderno's with an endpoint AND client ?
0
Comment
Question by:dbaSQL
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 25

Accepted Solution

by:
imitchie earned 1400 total points
ID: 20422196
>>what is the most appropriate way to restrict my dataset to only those orderno's with an endpoint AND client ?

select b.EndPoint,b.Client,min(a.latency) AS MIN, max(a.latency) AS MAX, AVG(a.latency) AS AVG, stdev(a.latency) AS StDEV
FROM tableA a inner join tableBp b WITH (NOLOCK)
ON a.orderno = b.orderno
WHERE b.Client is not null and b.EndPoint is not null
GROUP BY endpoint,client
0
 
LVL 17

Author Comment

by:dbaSQL
ID: 20422215
oh gosh.  unreal why i did not think of that.... jeeze
thank you ,imitchie
0
 
LVL 25

Expert Comment

by:imitchie
ID: 20422216
1., give me the stats on each endpoint, all clients

select
  b.EndPoint, min(a.latency) AS MIN, max(a.latency) AS MAX,
  AVG(a.latency) AS AVG, stdev(a.latency) AS StDEV
FROM tableA a
inner join tableBp b WITH (NOLOCK) ON a.orderno = b.orderno
WHERE b.Client is not null and b.EndPoint is not null  -- restricted
GROUP BY b.endpoint

2., give me the stats on each client, all endpoints

select
  b.Client, min(a.latency) AS MIN, max(a.latency) AS MAX,
  AVG(a.latency) AS AVG, stdev(a.latency) AS StDEV
FROM tableA a
inner join tableBp b WITH (NOLOCK) ON a.orderno = b.orderno
WHERE b.Client is not null and b.EndPoint is not null    -- restricted
GROUP BY b.Client

3., give me the stats on each endpoint/client pair  (this is the one posted below)
-- posted above
0
 
LVL 17

Author Comment

by:dbaSQL
ID: 20422221
surely i was overthinking that one.... missing the total obvious
ugh

again, though, thank you very much
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question