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

Database

 
AnswerRe: Entity Framework Book. Pin
Kevin Marois23-Jul-15 7:31
professionalKevin Marois23-Jul-15 7:31 
AnswerRe: Entity Framework Book. Pin
Mycroft Holmes23-Jul-15 14:10
professionalMycroft Holmes23-Jul-15 14:10 
QuestionSQL Linq, select from select and join Pin
jkirkerx21-Jul-15 13:27
professionaljkirkerx21-Jul-15 13:27 
SuggestionRe: SQL Linq, select from select and join Pin
Richard Deeming22-Jul-15 1:50
mveRichard Deeming22-Jul-15 1:50 
GeneralRe: SQL Linq, select from select and join Pin
jkirkerx22-Jul-15 6:02
professionaljkirkerx22-Jul-15 6:02 
GeneralRe: SQL Linq, select from select and join Pin
Richard Deeming22-Jul-15 8:00
mveRichard Deeming22-Jul-15 8:00 
GeneralRe: SQL Linq, select from select and join Pin
jkirkerx22-Jul-15 9:04
professionaljkirkerx22-Jul-15 9:04 
QuestionTrouble working with dates again and union and sum Pin
jkirkerx20-Jul-15 13:08
professionaljkirkerx20-Jul-15 13:08 
So I wrote this to represent the TSQL below
Not sure where I messed up, but I think it's the sum at the end.
I got one result for $46.51, but it should of been $0.00, now I broke it.
Using context As New OrdersContext

  Dim DateStart As DateTime = DateTime.Today.AddDays(-1)
  Dim DateStop As DateTime = DateTime.Today.AddDays(+1)

  pValue = _
      (From oh In context.Order_History
      Where oh.OrderStatus = "COMPLETED" _
      And oh.OrderDate > DateStart _
      And oh.OrderDate < DateStop
      Select oh).Union _
     (From oc In context.Order_Completed
     Where oc.OrderStatus = "QUEUED_FOR_FULFILLMENT" _
     Or oc.OrderStatus = "OUT_FOR_FULFILLMENT" _
     Or oc.OrderStatus = "QUEUED_FOR_SHIPPING" _
     Or oc.OrderStatus = "OUT_FOR_PACKAGING" _
     Or oc.OrderStatus = "READY_TO_SHIP" _
     And oc.OrderDate > DateStart _
     And oc.OrderDate < DateStop
    Select oc).Sum(Function(m) m.GrandTotal)

End Using

To represent this
DECLARE @StartDate AS Date; 
DECLARE @StopDate AS Date; 
SET @StartDate = CONVERT(CHAR(10),GETDATE(),101); 
SET @StopDate = CONVERT(CHAR(10),DATEADD(d,1, GETDATE()),101); 
WITH sums AS ( 
   SELECT SUM(GrandTotal) GrandTotal 
   FROM CompletedOrdersHistory 
   WHERE OrderStatus='COMPLETED' 
   AND OrderDate >= @StartDate 
   AND OrderDate < @StopDate  
   UNION ALL 
   SELECT SUM(GrandTotal) GrandTotal 
   FROM CompletedOrders 
   WHERE OrderStatus = 'QUEUED_FOR_FULFILLMENT' 
   OR OrderStatus = 'OUT_FOR_FULFILLMENT' 
   OR OrderStatus = 'QUEUED_FOR_SHIPPING' 
   OR OrderStatus = 'OUT_FOR_PACKAGING' 
   OR OrderStatus = 'READY_TO_SHIP' 
   AND OrderDate >= @StartDate 
   AND OrderDate < @StopDate 
) 
SELECT Sum(GrandTotal) AS GrandTotal 
FROM sums 

AnswerRe: Trouble working with dates again and union and sum Pin
jkirkerx20-Jul-15 13:34
professionaljkirkerx20-Jul-15 13:34 
Generalmake nullable type Pin
jkirkerx20-Jul-15 13:59
professionaljkirkerx20-Jul-15 13:59 
General[Got It] Pin
jkirkerx21-Jul-15 9:58
professionaljkirkerx21-Jul-15 9:58 
GeneralThe above post is incorrect - SQL Linq, Date Range, Union in VB Pin
jkirkerx22-Jul-15 8:54
professionaljkirkerx22-Jul-15 8:54 
GeneralRe: The above post is incorrect - SQL Linq, Date Range, Union in VB Pin
Mycroft Holmes22-Jul-15 14:15
professionalMycroft Holmes22-Jul-15 14:15 
GeneralRe: The above post is incorrect - SQL Linq, Date Range, Union in VB Pin
jkirkerx23-Jul-15 6:38
professionaljkirkerx23-Jul-15 6:38 
GeneralRe: The above post is incorrect - SQL Linq, Date Range, Union in VB Pin
Brisingr Aerowing23-Jul-15 7:37
professionalBrisingr Aerowing23-Jul-15 7:37 
GeneralRe: The above post is incorrect - SQL Linq, Date Range, Union in VB Pin
jkirkerx23-Jul-15 8:21
professionaljkirkerx23-Jul-15 8:21 
QuestionDatabase management Pin
Otekpo Emmanuel19-Jul-15 9:22
Otekpo Emmanuel19-Jul-15 9:22 
GeneralRe: Database management Pin
PIEBALDconsult19-Jul-15 9:40
mvePIEBALDconsult19-Jul-15 9:40 
AnswerRe: Database management Pin
Richard MacCutchan19-Jul-15 22:00
mveRichard MacCutchan19-Jul-15 22:00 
AnswerRe: Database management Pin
Mycroft Holmes19-Jul-15 22:32
professionalMycroft Holmes19-Jul-15 22:32 
AnswerRe: Database management Pin
Wendelius20-Jul-15 6:50
mentorWendelius20-Jul-15 6:50 
QuestionDatabase management Pin
Otekpo Emmanuel19-Jul-15 9:38
Otekpo Emmanuel19-Jul-15 9:38 
QuestionRe: Database management Pin
ZurdoDev22-Jul-15 9:48
professionalZurdoDev22-Jul-15 9:48 
Questionlarge database Pin
V.16-Jul-15 21:46
professionalV.16-Jul-15 21:46 
AnswerRe: large database Pin
Wendelius16-Jul-15 22:03
mentorWendelius16-Jul-15 22:03 

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.