Advertisement

08.09.2007 at 06:48AM PDT, ID: 22751962
[x]
Attachment Details

Comparing Numeric Range in SQL

Asked by JackW9653 in SQL Server 2005, Microsoft Visual Basic.Net

Tags: numeric, range, sql, comparing

Hello Experts,

I use the query below to determine the Sum of Minutes and Units for items that meet a specific criteria:
SELECT Sum(T.ContactMins) AS Minutes, Sum(T.Units) As Units
FROM tblTreatmentSummary T
LEFT JOIN LookupTreatments L ON L.Code = T.Treatment
WHERE L.Time_Based = 'Y' AND T.Encounter_Code = '168'

This returns numbers such as 43 minutes and 3 units. Now I need to compare the minutes to a range set in another table LookupUnits where the structure is:
Low (int)
High (int)
Units (int)
If the minutes returned in the above query fall between the Low and High and units match the predefined units in the table then the query should return True else False.

Thanks for any help,

JackW9653Start Free Trial
[+][-]08.09.2007 at 07:11AM PDT, ID: 19662290

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SQL Server 2005, Microsoft Visual Basic.Net
Tags: numeric, range, sql, comparing
Sign Up Now!
Solution Provided By: appari
Participating Experts: 2
Solution Grade: A
 
 
[+][-]08.09.2007 at 07:14AM PDT, ID: 19662316

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.09.2007 at 07:23AM PDT, ID: 19662390

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628