Click here to Skip to main content
15,911,360 members
Home / Discussions / Database
   

Database

 
GeneralRe: Sql Server Pin
Blue_Boy24-Apr-08 22:15
Blue_Boy24-Apr-08 22:15 
Generalschedule a procedure to run daily in a given time. Pin
yesu prakash24-Apr-08 18:47
yesu prakash24-Apr-08 18:47 
GeneralRe: schedule a procedure to run daily in a given time. Pin
Blue_Boy24-Apr-08 19:03
Blue_Boy24-Apr-08 19:03 
GeneralRe: schedule a procedure to run daily in a given time. Pin
yesu prakash24-Apr-08 20:11
yesu prakash24-Apr-08 20:11 
GeneralRe: schedule a procedure to run daily in a given time. Pin
GuyThiebaut24-Apr-08 22:03
professionalGuyThiebaut24-Apr-08 22:03 
GeneralHelp performing a count Pin
AdamskiR24-Apr-08 5:22
AdamskiR24-Apr-08 5:22 
GeneralRe: Help performing a count Pin
Kschuler24-Apr-08 8:37
Kschuler24-Apr-08 8:37 
GeneralRe: Help performing a count Pin
AdamskiR24-Apr-08 22:55
AdamskiR24-Apr-08 22:55 
Thanks for your reply.

For example

In the lookup table - DrugTherapy
DTID(int)          DrugTherapy(varchar)
1                  Drug1
2                  Drug2
3                  Drug3
4                  Drug4

Drug referrals made - ReferralDrugTherapy
DTRID(int)    ReferralID(int)      DTID(int)
1                  1                    1
2                  1                    1
3                  2                    4
4                  2                    3
5                  3                    2
6                  4                    2
7                  5                    1

Main Table CardiacReferrals
ReferralID(int)    Ward(int)            Comments(varchar)       DateSubmitted(datetime)
1                  1                    test                    01/01/2008
2                  2                    test1                   22/01/2008
3                  3                    test2                   01/02/2008
4                  1                    test543                 21/02/2008
5                  2                    test45                  01/02/2008
6                  3                    testtgdf                25/02/2008
7                  9                    testgdf                 05/03/2008
8                  5                    testggd                 11/03/2008
9                  6                    testfg                  12/03/2008
10                 4                    testgd                  07/04/2008


I have tried the following which works if there is values for the record, but if there isnt nothing is diplayed, what i want is for it to display 0 still if there is nothing there:

SELECT     DrugTherapy.DrugTherapy, COUNT(ReferralDrugTherapy.DTID) AS Expr1<br />
FROM         DrugTherapy INNER JOIN<br />
                      ReferralDrugTherapy ON DrugTherapy.DTID = ReferralDrugTherapy.DTID INNER JOIN<br />
                      CardiacReferrals ON ReferralDrugTherapy.ReferralID = CardiacReferrals.ReferralID<br />
WHERE     (CardiacReferrals.DateSubmitted BETWEEN @from AND @to) OR<br />
                      (CardiacReferrals.DateSubmitted IS NULL)<br />
GROUP BY DrugTherapy.DrugTherapy


Any help much appreciated. Smile | :)
GeneralRe: Help performing a count Pin
Blue_Boy24-Apr-08 23:00
Blue_Boy24-Apr-08 23:00 
GeneralRe: Help performing a count Pin
AdamskiR24-Apr-08 23:09
AdamskiR24-Apr-08 23:09 
GeneralRe: Help performing a count Pin
Blue_Boy24-Apr-08 23:19
Blue_Boy24-Apr-08 23:19 
GeneralRe: Help performing a count Pin
AdamskiR24-Apr-08 23:25
AdamskiR24-Apr-08 23:25 
GeneralRe: Help performing a count Pin
Blue_Boy24-Apr-08 23:48
Blue_Boy24-Apr-08 23:48 
GeneralRe: Help performing a count Pin
AdamskiR25-Apr-08 0:05
AdamskiR25-Apr-08 0:05 
GeneralRe: Help performing a count Pin
Kschuler25-Apr-08 3:20
Kschuler25-Apr-08 3:20 
GeneralRe: Help performing a count Pin
AdamskiR25-Apr-08 4:51
AdamskiR25-Apr-08 4:51 
GeneralRe: Help performing a count Pin
Kschuler25-Apr-08 4:54
Kschuler25-Apr-08 4:54 
GeneralRe: Help performing a count Pin
Blue_Boy25-Apr-08 5:00
Blue_Boy25-Apr-08 5:00 
GeneralRe: Help performing a count Pin
AdamskiR25-Apr-08 5:13
AdamskiR25-Apr-08 5:13 
GeneralRe: Help performing a count Pin
Blue_Boy25-Apr-08 5:17
Blue_Boy25-Apr-08 5:17 
GeneralRe: Help performing a count Pin
AdamskiR25-Apr-08 5:19
AdamskiR25-Apr-08 5:19 
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 

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.