Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help with Query
Message
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Help with Query
Divers
Thread ID:
00706345
Message ID:
00706345
Vues:
51
In the query below I am returning all rows of supply items used for a given date range. My ultimate goal is to limit the query to return only rows where the TotalUsed column calculate to less than some number passed by the user. I don't know how to do that part of it.
declare @tiDept as int
declare @DateFrom as datetime
declare @DateTo as DateTime
declare @tiMinUsage as int

set @tiDept = 1
set @dateFrom = '10/01/2001 00:00'
set @dateTo =   '10/01/2002 23:59'


SELECT  i.primedesc, i.catalogno, sum(c.actualqty) as TotalUsed,
	(Select isnull(dbo.coinv.medication,0)  from dbo.coinv where invid=i.invid) as Medication
        FROM    dbo.cocasedata c INNER JOIN
        dbo.coinv i ON c.linkedid = i.invid INNER JOIN
        dbo.meetings ON c.meetingnumber = dbo.meetings.meetingnumber
WHERE   (dbo.meetings.iscompleted = 1)
AND     dbo.meetings.begintime between @dateFrom and @dateTo
group by invid,primedesc,catalogno
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform