Click here to Skip to main content
15,888,237 members
Home / Discussions / Database
   

Database

 
GeneralRe: How to Sort this, Get Next Record ID when Many users inserting and different Districts Pin
GuyThiebaut6-Jun-14 2:24
professionalGuyThiebaut6-Jun-14 2:24 
GeneralRe: How to Sort this, Get Next Record ID when Many users inserting and different Districts Pin
ZurdoDev6-Jun-14 2:49
professionalZurdoDev6-Jun-14 2:49 
AnswerRe: How to Sort this, Get Next Record ID when Many users inserting and different Districts Pin
Eddy Vluggen6-Jun-14 2:36
professionalEddy Vluggen6-Jun-14 2:36 
AnswerRe: How to Sort this, Get Next Record ID when Many users inserting and different Districts Pin
PIEBALDconsult6-Jun-14 14:38
mvePIEBALDconsult6-Jun-14 14:38 
QuestionSQLite query Pin
David Crow5-Jun-14 10:38
David Crow5-Jun-14 10:38 
AnswerRe: SQLite query Pin
Mycroft Holmes5-Jun-14 12:47
professionalMycroft Holmes5-Jun-14 12:47 
GeneralRe: SQLite query Pin
David Crow5-Jun-14 17:38
David Crow5-Jun-14 17:38 
QuestionQuestion on Canidate keys and functional dependecies Pin
Member 108651294-Jun-14 16:35
Member 108651294-Jun-14 16:35 
AnswerRe: Question on Canidate keys and functional dependecies Pin
Eddy Vluggen5-Jun-14 8:05
professionalEddy Vluggen5-Jun-14 8:05 
AnswerRe: Question on Canidate keys and functional dependecies Pin
Eddy Vluggen6-Jun-14 23:39
professionalEddy Vluggen6-Jun-14 23:39 
QuestionIssue deploying SSIS Package in production web server Pin
Shuaib Kaniyar4-Jun-14 0:46
Shuaib Kaniyar4-Jun-14 0:46 
Question+ operaotor for outer joins in mysql. Pin
aghori3-Jun-14 19:55
aghori3-Jun-14 19:55 
AnswerRe: + operaotor for outer joins in mysql. Pin
Jörgen Andersson3-Jun-14 21:16
professionalJörgen Andersson3-Jun-14 21:16 
SuggestionData Mining Structure not Available in SSAS Tabular Model Pin
FLouis382-Jun-14 6:14
professionalFLouis382-Jun-14 6:14 
QuestionReady to give up on MySQL - is PostgreSQL better? Pin
Wombaticus1-Jun-14 22:09
Wombaticus1-Jun-14 22:09 
AnswerRe: Ready to give up on MySQL - is PostgreSQL better? Pin
Jörgen Andersson1-Jun-14 22:37
professionalJörgen Andersson1-Jun-14 22:37 
GeneralRe: Ready to give up on MySQL - is PostgreSQL better? Pin
Wombaticus1-Jun-14 22:43
Wombaticus1-Jun-14 22:43 
GeneralRe: Ready to give up on MySQL - is PostgreSQL better? Pin
Jörgen Andersson1-Jun-14 23:08
professionalJörgen Andersson1-Jun-14 23:08 
QuestionA query with lot of inner queries Pin
indian14329-May-14 12:41
indian14329-May-14 12:41 
Hi All,

I have the following query that is created by MS Access while creating report. But the query has lots of inner queries and joins. Can anybody please help in making this big query simple and by removing all the possible brackets and make it clean. Any type is very helpful. This query really taking a lot of time to understand it. Any link, tool name or way to solve it any help is very much helpful. Thanks in advance.

Here is the query.

SELECT so.EntityId, s.SponsorId, so.OrderId, so.ProgramId, so.ProgramYear, s.SponsorNbr, 
s.SponsorNme, s.VendorNbr, s.MailFdpCde, dbo.Reference.RefCde, dbo.Reference.ExtCde, dbo.FDPSponsorApp.CurrentInd, 
dbo.DeliveryPeriod.BegDte, dbo.DeliveryPeriod.EndDte, dbo.vwRef_fdpprogram.RefDsc, dbo.vwRef_fdpprogram.RefCde AS ProgramCde, dbo.Product.ProductCde, 
dbo.Product.ShortDsc as ProductDsc, sod.QtyInv AS QtyRcv, dbo.Product.NetPackWt, 
(CASE WHEN ((dbo.ProductCost.FixedCost IS NULL) OR (dbo.ProductCost.EntDrawInd= 653)) THEN ISNULL(dbo.ProductCost.WghtAvgCost, 0)
ELSE ISNULL(dbo.ProductCost.FixedCost,0) END) AS UnitCost, 
[QtyInv]*(CASE WHEN ((dbo.ProductCost.FixedCost IS NULL) OR (dbo.ProductCost.EntDrawInd= 653)) THEN ISNULL(dbo.ProductCost.WghtAvgCost, 0)
ELSE ISNULL(dbo.ProductCost.FixedCost,0) END) AS  ValueRcvd, 
[NetPackWt]*[QtyInv] AS [Total Pounds], dbo.Contact.FirstNme, dbo.Contact.LastNme, dbo.Address.Addr1, dbo.Address.Addr2, 
dbo.Address.City, dbo.Address.State, dbo.Address.ZipCde, dbo_Reference_1.RefDsc AS DeliveryType, so.DeliveryTypeId, 
dbo.RefYearDefaults.DefValue AS BrownBoxFee, dbo_RefYearDefaults_1.DefValue AS DirectDiversionFee, dbo.Product.NetPackWt, s.VendorNbr, 
s.FedEmpIdNbr 
FROM dbo.RefYearDefaults AS dbo_RefYearDefaults_1  
INNER JOIN (dbo.RefYearDefaults  
INNER JOIN ((dbo.Reference  
INNER JOIN ((dbo.Contact  
INNER JOIN (dbo.Address  
INNER JOIN (dbo.ProductCost  
INNER JOIN (dbo.Sponsor s 
INNER JOIN (dbo.FDPSponsorApp  
INNER JOIN ((((dbo.FDPEntity  
INNER JOIN dbo.SponsorOrder so ON dbo.FDPEntity.EntityId = so.LocationId)  
INNER JOIN dbo.SponsorOrderDetail sod ON so.OrderId = sod.OrderId)  
INNER JOIN dbo.Product ON sod.ProductId = dbo.Product.ProductId)  
INNER JOIN dbo.DeliveryPeriod ON (so.DeliveryPeriodId = dbo.DeliveryPeriod.DeliveryPeriodId) 	
AND (so.ProgramYear = dbo.DeliveryPeriod.ProgramYear)) ON (dbo.FDPSponsorApp.EntityId = 
so.EntityId) 	AND (dbo.FDPSponsorApp.ProgramYear = so.ProgramYear)) ON s.SponsorId = dbo.FDPSponsorApp.SponsorId) ON 
(dbo.ProductCost.ProgramYear = dbo.FDPSponsorApp.ProgramYear) 	AND (dbo.ProductCost.ProductId = dbo.Product.ProductId)) ON dbo.Address.AddrId = 
dbo.FDPSponsorApp.MailAddrId) ON dbo.Contact.ContactId = dbo.FDPSponsorApp.FdpCtcId)  INNER JOIN dbo.vwRef_fdpprogram ON so.ProgramId = 
dbo.vwRef_fdpprogram.RefId) ON dbo.Reference.RefId = s.SFMSObjectTypeId)  INNER JOIN dbo.Reference AS dbo_Reference_1 ON so.DeliveryTypeId = 
dbo_Reference_1.RefId) ON dbo.RefYearDefaults.ProgramYear = so.ProgramYear) ON dbo_RefYearDefaults_1.ProgramYear = so.ProgramYear 
WHERE (((so.ProgramYear)= 2014) 	AND --so.EntityId  = @SponsorEntityId	AND 
((dbo.FDPSponsorApp.CurrentInd)=1) 	AND ((sod.QtyInv)>0) 	AND ((dbo.RefYearDefaults.DefNme)='BrownBoxFee')	
AND ((dbo_RefYearDefaults_1.DefNme)='DirectDiversionFee')) ORDER BY so.EntityId, s.SponsorNme, so.OrderId, Product.ShortDsc

Thanks & Regards,

Abdul Aleem Mohammad
St Louis MO - USA

AnswerRe: A query with lot of inner queries Pin
Mycroft Holmes29-May-14 13:02
professionalMycroft Holmes29-May-14 13:02 
GeneralRe: A query with lot of inner queries Pin
indian14329-May-14 13:09
indian14329-May-14 13:09 
GeneralRe: A query with lot of inner queries Pin
Mycroft Holmes29-May-14 14:08
professionalMycroft Holmes29-May-14 14:08 
AnswerRe: A query with lot of inner queries Pin
Jörgen Andersson29-May-14 22:20
professionalJörgen Andersson29-May-14 22:20 
GeneralRe: A query with lot of inner queries Pin
Mycroft Holmes30-May-14 1:50
professionalMycroft Holmes30-May-14 1:50 
GeneralRe: A query with lot of inner queries Pin
Jörgen Andersson30-May-14 3:15
professionalJörgen Andersson30-May-14 3:15 

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.