asp.net - Combine Select Statements -
i building dashboard screen requires multiple sql statements return data. of these database calls adding in regards performance.
as stands code calls online meaning i'm making database calls inside code. move of database calls stored procedure not sure how combine of database calls 1 stored procedure return multiple values have display each of values individually.
can show me how combine these select statements 1 , return multiple values yo used inside code.
/*pending count */ select count(*) issue issue.workerkeyfk = lngworkerkey , issue.closeddate null /* today's issue count */ select count(*) issue issue.workerkeyfk = lngworkerkey , issue.issuedate = formatdatetime(datetimes, dateformat.shortdate) /* on due issue count */ select count(*) issue issue.workerkeyfk = lngworkerkey , issue.duedate < formatdatetime(datetimes, dateformat.shortdate) , issue.closeddate null /*get closed issue count */ select count(*) issue issue.workerkeyfk = lngworkerkey , issue.closeddate not null
here's how it:
select sum(iif(issue.issuedate = formatdatetime(datetimes, dateformat.shortdate), 1, 0) today_issue_count , sum(iif(issue.duedate < formatdatetime(datetimes, dateformat.shortdate) , issue.closeddate null, 1, 0) overdue_issue_count , sum(iif(issue.closeddate not null, 1, 0) closed_issue_count issue issue.workerkeyfk = lngworkerkey that way have 1 resultset deal with, , execution should pretty quick on server.
Comments
Post a Comment