Click here to Skip to main content
15,917,610 members
Home / Discussions / Database
   

Database

 
GeneralRe: Help performing a count Pin
Blue_Boy25-Apr-08 5:29
Blue_Boy25-Apr-08 5:29 
GeneralRe: Help performing a count Pin
AdamskiR25-Apr-08 5:32
AdamskiR25-Apr-08 5:32 
GeneralRe: Help performing a count Pin
Blue_Boy25-Apr-08 5:35
Blue_Boy25-Apr-08 5:35 
GeneralRe: Help performing a count Pin
AdamskiR25-Apr-08 5:45
AdamskiR25-Apr-08 5:45 
GeneralRe: Help performing a count Pin
Blue_Boy25-Apr-08 5:54
Blue_Boy25-Apr-08 5:54 
GeneralRe: Help performing a count Pin
AdamskiR25-Apr-08 5:56
AdamskiR25-Apr-08 5:56 
GeneralRe: Help performing a count Pin
Blue_Boy25-Apr-08 6:00
Blue_Boy25-Apr-08 6:00 
GeneralRe: Help performing a count Pin
Blue_Boy25-Apr-08 9:10
Blue_Boy25-Apr-08 9:10 
I guess this time I got the right solution

declare @fromdate as varchar(15)<br />
declare @todate as varchar(15)<br />
set @fromdate = '01/02/2008'<br />
set @todate = '05/02/2008'<br />
select ReferralDrugTherapy.dtid ,count(ReferralDrugTherapy.dtid) as countAll,DrugTherapy.DrugTherapy <br />
from ReferralDrugTherapy,CardiacReferrals,DrugTherapy<br />
where ReferralDrugTherapy.referralid =CardiacReferrals.referralid and  datesubmitted <br />
between convert(varchar,@fromdate,103) and  convert(varchar,@todate,103) and DrugTherapy.dtid = ReferralDrugTherapy.dtid<br />
group by ReferralDrugTherapy.dtid ,DrugTherapy.DrugTherapy<br />
union all<br />
select dtid,0,DrugTherapy.DrugTherapy  from DrugTherapy where dtid not in (<br />
select ReferralDrugTherapy.dtid  from ReferralDrugTherapy,CardiacReferrals,DrugTherapy<br />
where ReferralDrugTherapy.referralid =CardiacReferrals.referralid and  datesubmitted <br />
between convert(varchar,@fromdate,103) and  convert(varchar,@todate,103) and DrugTherapy.dtid = ReferralDrugTherapy.dtid<br />
group by ReferralDrugTherapy.dtid ,DrugTherapy.DrugTherapy)<br />
order by ReferralDrugTherapy.dtid asc



I Love T-SQL

GeneralRe: Help performing a count Pin
AdamskiR1-May-08 23:31
AdamskiR1-May-08 23:31 
GeneralRe: Help performing a count Pin
Blue_Boy1-May-08 23:41
Blue_Boy1-May-08 23:41 
GeneralRe: Help performing a count Pin
AdamskiR1-May-08 23:42
AdamskiR1-May-08 23:42 
GeneralRe: Help performing a count Pin
Blue_Boy1-May-08 23:50
Blue_Boy1-May-08 23:50 
GeneralRe: Help performing a count Pin
AdamskiR9-May-08 4:08
AdamskiR9-May-08 4:08 
GeneralRe: Help performing a count Pin
Blue_Boy9-May-08 7:09
Blue_Boy9-May-08 7:09 
QuestionHOW TO MERGE IN ONE! Pin
kibromg24-Apr-08 4:25
kibromg24-Apr-08 4:25 
AnswerRe: HOW TO MERGE IN ONE! [modified] Pin
Blue_Boy24-Apr-08 9:52
Blue_Boy24-Apr-08 9:52 
QuestionSQL 2000 ----- Extracting Rows from Delimited Strings Pin
n1coltsfan24-Apr-08 2:35
n1coltsfan24-Apr-08 2:35 
GeneralRe: SQL 2000 ----- Extracting Rows from Delimited Strings Pin
Blue_Boy24-Apr-08 8:36
Blue_Boy24-Apr-08 8:36 
GeneralRe: SQL 2000 ----- Extracting Rows from Delimited Strings Pin
n1coltsfan25-Apr-08 4:42
n1coltsfan25-Apr-08 4:42 
GeneralRe: SQL 2000 ----- Extracting Rows from Delimited Strings Pin
Blue_Boy25-Apr-08 5:01
Blue_Boy25-Apr-08 5:01 
GeneralSelection between ranges in sql server 2005 Pin
salon24-Apr-08 2:00
salon24-Apr-08 2:00 
GeneralRe: Selection between ranges in sql server 2005 Pin
Broken Bokken24-Apr-08 2:37
Broken Bokken24-Apr-08 2:37 
GeneralCount number of records in related tables Pin
Kevin Brydon24-Apr-08 0:54
Kevin Brydon24-Apr-08 0:54 
GeneralRe: Count number of records in related tables Pin
Ashfield24-Apr-08 1:30
Ashfield24-Apr-08 1:30 
GeneralRe: Count number of records in related tables Pin
Kevin Brydon24-Apr-08 2:49
Kevin Brydon24-Apr-08 2:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.