Paste Search Dynamic
Recent pastes
facility transactions
  1. -- create a table
  2. create table facility_transactions (
  3.   Transaction_ID INTEGER primary key,
  4.   Date timestamp not null,
  5.   Facility_Hashkey TEXT not null,
  6.   Type TEXT not null
  7. );
  8. -- insert some values
  9. insert into facility_transactions values (1, '2010-12-31 23:59:59', 'HA', 'Disbursal');
  10. insert into facility_transactions values (2, '2010-12-31 21:59:59', 'HM', 'Drawdown Fee');
  11. insert into facility_transactions values (3, '2010-12-31 23:59:59', 'HC', 'Account Fee');
  12. insert into facility_transactions values (4, '2010-12-30 22:59:59', 'HM', 'Drawdown Fee');
  13. insert into facility_transactions values (5, '2010-12-31 22:59:59', 'HM', 'Disbursal');
  14. insert into facility_transactions values (6, '2010-12-27 23:59:59', 'HC', 'Drawdown Fee');
  15. insert into facility_transactions values (7, '2010-12-28 23:59:59', 'HC', 'Account Fee');
  16. insert into facility_transactions values (8, '2010-12-31 22:59:59', 'HR', 'Disbursal');
  17. insert into facility_transactions values (9, '2010-12-27 23:59:59', 'HC', 'Drawdown Fee');
  18. insert into facility_transactions values (10, '2010-12-28 23:59:59', 'HR', 'Account Fee');
  19. insert into facility_transactions values (11, '2010-12-31 22:59:59', 'HM', 'Disbursal');
  20. insert into facility_transactions values (12, '2010-12-27 23:59:59', 'HO', 'Drawdown Fee');
  21. insert into facility_transactions values (13, '2010-12-28 23:59:59', 'HC', 'Account Fee');
  22. insert into facility_transactions values (14, '2010-12-31 22:59:59', 'HM', 'Disbursal');
  23. insert into facility_transactions values (15, '2010-12-27 23:59:59', 'HD', 'Drawdown Fee');
  24. insert into facility_transactions values (16, '2010-12-28 23:59:59', 'H9', 'Account Fee');
  25. -- fetch some values
  26. select * from facility_transactions;
  27. select Facility_Hashkey,
  28. (select count(*) from facility_transactions group by Facility_Hashkey) count
  29. NTILE(10) OVER (
  30. PARTITION by Facility_Hashkey
  31. order by count
  32. )
  33. from facility_transactions;
Parsed in 0.015 seconds