1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| StringBuilder sb = new StringBuilder();
sb.Append(" SELECT ");
sb.Append(" COUNT(*) AS cnt,");
sb.Append(" PhysicalBag.ID,");
sb.Append(" PhysicalBag.Number,");
sb.Append(" PhysicalBag.FillingLevel AS FLev,");
sb.Append(" PhysicalBag.OpenDate,");
sb.Append(" PhysicalBag.CloseRequestDate AS CloseNeedDt,");
sb.Append(" PhysicalBag.CloseRequiredDate AS CloseAskedDt,");
sb.Append(" PhysicalBag.CloseDate AS CloseDt,");
sb.Append(" PhysicalBag.ParcelCollectDefer AS ColectDay,");
sb.Append(" PhysicalBag.ReceivedDate AS ReceivedDt,");
sb.Append(" PhysicalBag.DispatchedDate,");
sb.Append(" Affiliate.HRK,");
sb.Append(" Affiliate.Name,");
sb.Append(" Affiliate.PhoneNumber,");
sb.Append(" Affiliate.FaxNumber,");
sb.Append(" Affiliate.GSMNumber,");
sb.Append(" Affiliate.Email");
sb.Append(" FROM");
sb.Append(" PhysicalBag ");
sb.Append(" INNER JOIN Affiliate ON PhysicalBag.AffiliateID = Affiliate.ID ");
sb.Append(" INNER JOIN VirtualBag ON PhysicalBag.ID = VirtualBag.PhysicalBagID ");
sb.Append(" INNER JOIN TradeIn ON VirtualBag.ID = TradeIn.VirtualBagID");
sb.Append(" where (PhysicalBag.OpenDate < CONVERT(DATETIME, '2010-07-30 00:00:00', 102)) ");
sb.Append(" AND (PhysicalBag.CloseDate IS NULL) ");
sb.Append(" AND (PhysicalBag.CloseRequestDate IS NULL) ");
sb.Append(" GROUP BY PhysicalBag.ID,");
sb.Append(" PhysicalBag.Number,");
sb.Append(" PhysicalBag.FillingLevel,");
sb.Append(" PhysicalBag.OpenDate,");
sb.Append(" PhysicalBag.CloseRequestDate,");
sb.Append(" PhysicalBag.CloseRequiredDate, ");
sb.Append(" PhysicalBag.CloseDate,");
sb.Append(" PhysicalBag.ParcelCollectDefer,");
sb.Append(" PhysicalBag.ReceivedDate,");
sb.Append(" PhysicalBag.DispatchedDate,");
sb.Append(" Affiliate.HRK, Affiliate.Name, ");
sb.Append(" Affiliate.PhoneNumber,");
sb.Append(" Affiliate.FaxNumber,");
sb.Append(" Affiliate.GSMNumber,");
sb.Append(" Affiliate.Email");
sb.Append(" having (COUNT(*)>5)"); |
Partager