Click here to Skip to main content
15,902,938 members
Home / Discussions / Database
   

Database

 
GeneralReplication in Pocket PC Pin
Widgets24-Jan-08 2:37
Widgets24-Jan-08 2:37 
GeneralRe: Replication in Pocket PC Pin
GuyThiebaut24-Jan-08 5:29
professionalGuyThiebaut24-Jan-08 5:29 
QuestionOpen a MySQL database from SQL Server Pin
adi.rusu24-Jan-08 1:09
adi.rusu24-Jan-08 1:09 
GeneralRe: Open a MySQL database from SQL Server Pin
Justin Perez24-Jan-08 3:21
Justin Perez24-Jan-08 3:21 
GeneralComparing Dates in Query Pin
blackjack215023-Jan-08 23:46
blackjack215023-Jan-08 23:46 
GeneralRe: Comparing Dates in Query Pin
PIEBALDconsult24-Jan-08 4:34
mvePIEBALDconsult24-Jan-08 4:34 
Questionassigning xml to a sql table in SQL SERVER using INSERT statement Pin
Nisha_Aadhi23-Jan-08 23:45
Nisha_Aadhi23-Jan-08 23:45 
GeneralError upon login Pin
samerh23-Jan-08 22:43
samerh23-Jan-08 22:43 
GeneralRe: Error upon login Pin
MrPlankton24-Jan-08 10:31
MrPlankton24-Jan-08 10:31 
GeneralRe: Error upon login Pin
samerh24-Jan-08 19:34
samerh24-Jan-08 19:34 
QuestionWhat is Wrong with the Following Procedure Pin
Vimalsoft(Pty) Ltd23-Jan-08 20:08
professionalVimalsoft(Pty) Ltd23-Jan-08 20:08 
AnswerRe: What is Wrong with the Following Procedure Pin
Joe23-Jan-08 23:58
Joe23-Jan-08 23:58 
AnswerRe: What is Wrong with the Following Procedure Pin
Vimalsoft(Pty) Ltd24-Jan-08 0:14
professionalVimalsoft(Pty) Ltd24-Jan-08 0:14 
GeneralRe: What is Wrong with the Following Procedure Pin
Joe24-Jan-08 1:49
Joe24-Jan-08 1:49 
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 

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.