Click here to Skip to main content
15,889,335 members
Home / Discussions / Database
   

Database

 
General'Parameter1' is missing a value .rdlc report error Pin
Member 470022523-Jan-08 17:55
Member 470022523-Jan-08 17:55 
Generalcode for transfering data from access to Sql server,giving error SqlException Pin
Cuckoo23-Jan-08 17:44
Cuckoo23-Jan-08 17:44 
GeneralRe: code for transfering data from access to Sql server,giving error SqlException Pin
pmarfleet23-Jan-08 19:48
pmarfleet23-Jan-08 19:48 
GeneralRe: code for transfering data from access to Sql server,giving error SqlException Pin
Paddy Boyd24-Jan-08 2:20
Paddy Boyd24-Jan-08 2:20 
GeneralUpdate with Addition Pin
Expert Coming23-Jan-08 14:47
Expert Coming23-Jan-08 14:47 
GeneralRe: Update with Addition Pin
pmarfleet23-Jan-08 19:46
pmarfleet23-Jan-08 19:46 
GeneralRe: Update with Addition Pin
Paddy Boyd24-Jan-08 2:21
Paddy Boyd24-Jan-08 2:21 
QuestionIs there a way to optimize this query and get the same results? Pin
Skanless23-Jan-08 11:21
Skanless23-Jan-08 11:21 
I have a query which I am running accross several DB's to get information on several of our store's oulet. The query Below provided the info I need but I am not sure if it is the best way to do it and how it will be affected when we have millions of record in our DB. Or can I make it into a single query so when executed in C# I do do get two table in my dataset. Any comment or suggestion is appreciated.

Select 'My Business' AS BusName, sum(PassVer.PassedVerifier) AS 'Passed Verifiers', Sum(PassVer.CashFunded)AS 'Cash Funded', SUM(PassVer.OtherFunding) AS 'Other Funding', Sum(PassVer.CompletedApplications) AS 'Completed Applications', SUM(PassVer.CompleteFundedCash) AS 'Complete - Funded Cash', SUM(Passver.CompleteNotFundedCash) AS 'Complete-Not Cash', SUM(PassVer.Total) AS 'Total Applications',
	cast((Sum(PassVer.PassedVerifier) * 100.00) / sum(PassVer.CompletedApplications)  AS Float) AS '% Completed and verified',
	cast((SUM(PassVer.CompletedApplications)* 100.00) / Sum(PassVer.Total)  AS Float) AS '% of Completed from Total'
FROM (
--Selects Applications which Passed Verifier
Select 1 AS 'PassedVerifier', 0 As 'CashFunded', 0 As 'OtherFunding', 0 AS 'CompletedApplications', 0 AS 'CompleteFundedCash', 0 AS 'CompleteNotFundedCash', 0 AS 'Total'
FROM dbo.BK_Account A LEFT JOIN dbo.BK_AccountQueue Q ON
A.Guid=Q.AccountGuid
where Q.QueueId= 'Pass Validation'
UNION ALL

--Selects Applications which passed the verifier and are funded by Cash.
SELECT 0 AS 'PassedVerifier', 1 AS 'CashFunded', 0 As 'OtherFunding', 0 AS 'CompletedApplications', 0 AS 'CompleteFundedCash', 0 AS 'CompleteNotFundedCash', 0 AS 'Total'
FROM dbo.BK_Account A LEFT JOIN dbo.BK_AccountQueue Q ON
A.Guid=Q.AccountGuid
where A.fundingMethodId = 'Cash' and Q.QueueId= 'Pass Validation'
UNION ALL

--Selects Applications which passed the verifier and are funded by methods other than Cash.
SELECT 0 AS 'PassedVerifier', 0 AS 'CashFunded', 1 As 'OtherFunding', 0 AS 'CompletedApplications',0 AS 'CompleteFundedCash',  0 AS 'CompleteNotFundedCash', 0 AS 'Total'
FROM dbo.BK_Account A LEFT JOIN dbo.BK_AccountQueue Q ON
A.Guid=Q.AccountGuid
where A.fundingMethodId != 'Cash' and Q.QueueId= 'Pass Validation'
UNION ALL

--Selects Applications which are completed.
SELECT 0 AS 'PassedVerifier', 0 AS 'CashFunded', 0 As 'OtherFunding', 1 AS 'CompletedApplications', 0 AS 'CompleteFundedCash', 0 AS 'CompleteNotFundedCash', 0 AS 'Total'
FROM dbo.BK_Account A LEFT JOIN dbo.BK_AccountQueue Q ON
A.Guid=Q.AccountGuid
where Q.QueueId= 'Application Completed'
UNION ALL

--Selects Applications which are completed and are funded by Cash.
SELECT 0 AS 'PassedVerifier', 0 AS 'CashFunded', 0 As 'OtherFunding', 0 AS 'CompletedApplications', 1 AS 'CompleteFundedCash',  0 AS 'CompleteNotFundedCash', 0 AS 'Total' 
FROM dbo.BK_Account A LEFT JOIN dbo.BK_AccountQueue Q ON
A.Guid=Q.AccountGuid
where Q.QueueId= 'Application Completed' and A.fundingMethodId = 'Cash'
UNION ALL

--Selects Applications which are completed and are not funded by Cash.
SELECT 0 AS 'PassedVerifier', 0 AS 'CashFunded', 0 As 'OtherFunding', 0 AS 'CompletedApplications', 0 AS 'CompleteFundedCash',  1 AS 'CompleteNotFundedCash', 0 AS 'Total'
FROM dbo.BK_Account A LEFT JOIN dbo.BK_AccountQueue Q ON
A.Guid=Q.AccountGuid
where Q.QueueId= 'Application Completed' and A.fundingMethodId != 'Cash'
UNION ALL

--Total amount of applications.
SELECT 0 AS 'PassedVerifier', 0 AS 'CashFunded', 0 As 'OtherFunding', 0 AS 'CompletedApplications', 0 AS 'CompleteFundedCash',  0 AS 'CompleteNotFundedCash', 1 AS 'Total'
FROM dbo.BK_Account) PassVer


SELECT 'My Business' AS BusName,
CASE WHEN GROUPING (CAST(MONTH(A.CreationDate) AS VARCHAR))= 1 THEN 'Grand Total' 
else (CAST(MONTH(A.CreationDate) AS VARCHAR)) end as MonthCreated,
Count(*) AS TotalCompletedApplications,
SUM(A.FundingAmount) AS SumTotalCompletedApplications
FROM dbo.BK_Account A LEFT JOIN dbo.BK_AccountQueue Q ON
A.Guid=Q.AccountGuid
WHERE (A.Visible = 1) AND (Q.QueueId= 'Pass Validation' ) 
GROUP BY (CAST(MONTH(A.CreationDate) AS VARCHAR))
With rollup


Skan

If you knew it would not compile why didn't you tell me?!?!?!

AnswerRe: Is there a way to optimize this query and get the same results? Pin
PIEBALDconsult23-Jan-08 14:30
mvePIEBALDconsult23-Jan-08 14:30 
GeneralBuilding up a query string Pin
ssTahoe23-Jan-08 7:48
ssTahoe23-Jan-08 7:48 
GeneralCreating a CLR User Defined Type for Time only Pin
AAGTHosting23-Jan-08 7:25
AAGTHosting23-Jan-08 7:25 
GeneralHelp in Stored Procedure sqlserver Pin
aaraaayen22-Jan-08 20:55
aaraaayen22-Jan-08 20:55 
GeneralRe: Help in Stored Procedure sqlserver Pin
pmarfleet22-Jan-08 22:07
pmarfleet22-Jan-08 22:07 
GeneralRe: Help in Stored Procedure sqlserver Pin
KANGAROO_22-Jan-08 22:25
KANGAROO_22-Jan-08 22:25 
GeneralRe: Help in Stored Procedure sqlserver Pin
andyharman22-Jan-08 22:34
professionalandyharman22-Jan-08 22:34 
GeneralRe: Help in Stored Procedure sqlserver Pin
aaraaayen22-Jan-08 23:31
aaraaayen22-Jan-08 23:31 
GeneralRe: Help in Stored Procedure sqlserver Pin
aaraaayen23-Jan-08 0:02
aaraaayen23-Jan-08 0:02 
GeneralAttaching an .MDF file without an LDF file Pin
ffowler22-Jan-08 11:25
ffowler22-Jan-08 11:25 
GeneralRe: Attaching an .MDF file without an LDF file Pin
Mike Dimmick23-Jan-08 12:40
Mike Dimmick23-Jan-08 12:40 
QuestionSybase Linked Server Pin
mobius11100122-Jan-08 3:22
mobius11100122-Jan-08 3:22 
QuestionHow to use one sp's result in my new Sp Pin
pashitech21-Jan-08 18:26
pashitech21-Jan-08 18:26 
AnswerRe: How to use one sp's result in my new Sp Pin
Joe21-Jan-08 18:49
Joe21-Jan-08 18:49 
AnswerRe: How to use one sp's result in my new Sp Pin
andyharman22-Jan-08 0:13
professionalandyharman22-Jan-08 0:13 
GeneralCreating a User Defined Type For Time Pin
AAGTHosting21-Jan-08 13:46
AAGTHosting21-Jan-08 13:46 
GeneralRe: Creating a User Defined Type For Time Pin
PIEBALDconsult21-Jan-08 14:54
mvePIEBALDconsult21-Jan-08 14:54 

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.