Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 count the quantity of payments with 20000 step

Author  Topic 

ecivgamer
Starting Member

7 Posts

Posted - 2014-01-17 : 13:36:21
Hi all,



my need is to count the quantity of payments with 20000 step.
This is my Oracle code. I'm in process of moving from Oracle to SQL Server. Please, be so kind, help me to rewrite this code for SQL Server. Thanks ahead.

WITH got_grps AS

(

SELECT TRUNC (sys_creation_date) AS date_creation

, ( 1

+ FLOOR ( NVL (amount_original, 0)

/ 20000

)

) * 20000 AS grp_20000

FROM event_log

WHERE sys_creation_date BETWEEN SYSDATE - 1000

AND SYSDATE

AND policy_action = 'REVIEW'

AND NVL (amount_original, 0) >= 1

)

SELECT date_creation, grp_20000

, COUNT (*) AS cnt

FROM got_grps

GROUP BY date_creation, grp_20000

ORDER BY date_creation, grp_20000

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-01-18 : 02:14:52
given the answer here
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/ee67702a-97cc-4a9f-9aba-41f163a518b4/count-rows-with-sum-range?forum=sqlgetstarted

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -