ich eine Tabelle wie unten Struktur haben:, wie eine Abfrage zu tun, indem sie einige ausgewählte Daten auf Gruppe auszuwählen
ID|PrcessorID|BatchNO|NoOfTransaction|BatchCreatedDate
1 |20 |2 |3 |2017-03-28
2 |21 |3 |3 |2017-04-01
3 |21 |4 |7 |2017-04-01
4 |20 |5 |3 |2017-04-01
5 |21 |6 |2 |2017-04-02
6 |20 |7 |4 |2017-04-02
und eine andere Tabelle ist wie
ProcessorID|ProcessorName
20 |Payme
21 |Payany
ich die Daten insgesamt bekommen haben Anzahl der Transaktionen und Anzahl der Charge an jedem bestimmten Datum von jedem spezifischen Prozessor von vor 3 Tagen Gruppe durch den Prozessor, so dass ich Daten wie erhalten kann:
, was ich jetzt bin doin ist:
Select a.ProcessorId As ProcessorID,b.ProcessorName As ProcessorName,BatchCreatedDate,Sum(NoofTRansaction) As TotNoofTransaction,Count(BatchNo) As BatchCountfrom TableA a innerjoin TableB b on a.ProcessorID=b.ProcessorID where BatchcreatedDate<GetDate() and BatchCreatedDate>GetDate()-4 groupby ProcessorName,BatchCreatedDate
aber diese Abfrage gibt mir führen wie
PrcessorName|Batchcount|TotNoOfTransaction|BatchCreatedDate
Payany |1 |3 |2017-04-01
Payany |1 |7 |2017-04-01
Payme |1 |3 |2017-04-01
Payany |1 |2 |2017-04-02
Payme |1 |4 |2017-04-02
ja sein ein Datetime-Feld – Tanmay