![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a table CourtCase with following fields: CourtCaseId (PK int) CourtLevelId (FK int) CourtId (FK int) CaseNumber (varchar) isDecided (bool) isDeleted (bool) I have another table CourtLevel with following fields CourtlevelId, CourtTitle I have a stored procedure which takes 2 parameters: CourtLevelId, CourtId I have to get the following data based on courtlevelid and courtid CourtTitle, TotalCase I need to get following details based on CourtlevelId and CourtId Courttitle, TotalCases, Total Cases where isdecided=1, total cases where isdecided=1 and isdeleted=0 |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
This query works just fine. However it returns only one courtleveltitle. More than one courtleveltitle exist for @courtid and @courtlevelid select 1 as courtlevel,l.courtleveltitle, 'abc' as url, COUNT(*) as total, SUM(case isdecided when 1 then 1 else 0 end)as decided, SUM(case isdecided when 0 then 1 else 0 end)as pending, SUM(case isdecided when 1 then 1 else 0 end)-SUM(case when c.isdecided=1 and right(c.DecisionOrderFile,1)='/' then 1 else 0 end) as uploadfrom CourtCase as c join CourtLevels as l on c.CourtLevelID=l.CourtLevelID where c.CourtLevelID=@CourtLevelid and c.CourtID=@CourtId group by l.courtleveltitle |
#5
| |||
| |||
|
|
This query works just fine. However it returns only one courtleveltitle. More than one courtleveltitle exist for @courtid and @courtlevelid select 1 as courtlevel,l.courtleveltitle, 'abc' as url, COUNT(*) as total, SUM(case isdecided when 1 then 1 else 0 end)as decided, SUM(case isdecided when 0 then 1 else 0 end)as pending, SUM(case isdecided when 1 then 1 else 0 end)- SUM(case when c.isdecided=1 and right(c.DecisionOrderFile,1)='/' then 1 else 0 end) as upload from CourtCase as c join CourtLevels as l on c.CourtLevelID=l.CourtLevelID where c.CourtLevelID=@CourtLevelid and c.CourtID=@CourtId group by l.courtleveltitle |
![]() |
| Thread Tools | |
| Display Modes | |
| |