Subversion Repositories SmartDukaan

Rev

Rev 5711 | Rev 6322 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5711 Rev 5768
Line 63... Line 63...
63
  </select>
63
  </select>
64
 
64
 
65
  <select id="getInventoryAge" resultType="inventoryAge">
65
  <select id="getInventoryAge" resultType="inventoryAge">
66
    SELECT t.itemId, brand, modelName, modelNumber, color,
66
    SELECT t.itemId, brand, modelName, modelNumber, color,
67
        SUM((age &lt; 1) * currentQuantity) AS freshCount, 
67
        SUM((age &lt; 1) * currentQuantity) AS freshCount, 
68
        SUM((age between 1 and 2) * currentQuantity) AS oneToTwoCount, 
68
        SUM((age &gt;= 1 and age &lt; 2) * currentQuantity) AS oneToTwoCount, 
69
        SUM((age between 2 and 3) * currentQuantity) AS twoToThreeCount, 
69
        SUM((age &gt;= 2 and age &lt; 3) * currentQuantity) AS twoToThreeCount, 
70
        SUM((age between 3 and 4) * currentQuantity) AS threeToFourCount, 
70
        SUM((age &gt;= 3 and age &lt; 4) * currentQuantity) AS threeToFourCount, 
71
        SUM((age &gt; 4) * currentQuantity) as fourPlusCount
71
        SUM((age &gt;= 4) * currentQuantity) as fourPlusCount,
-
 
72
        SUM((age &gt;= 1) * currentQuantity) as onePlusCount,
-
 
73
        SUM((age &gt;= 1) * unitPrice) as onePlusCost,
-
 
74
        SUM(currentQuantity) as zeroPlusCount,
-
 
75
        SUM(l.unitPrice) as zeroPlusCost,
-
 
76
        l.productGroup as category
72
    FROM  (SELECT ii.id, ii.itemId, ii.currentQuantity, ii.purchaseId,
77
    FROM  (SELECT ii.id, ii.itemId, ii.currentQuantity, ii.purchaseId,
73
                DATEDIFF(now(), MAX(s.scannedAt)) / 7 as age
78
                DATEDIFF(now(), MAX(s.scannedAt)) / 7 as age
74
           FROM inventoryItem ii 
79
           FROM inventoryItem ii 
75
           JOIN scanNew s 
80
           JOIN scanNew s 
76
                ON (s.inventoryItemId = ii.id) 
81
                ON (s.inventoryItemId = ii.id)