|
@ -1589,7 +1589,401 @@ ALTER TABLE organization ALTER COLUMN is_join SET DEFAULT '0';
|
1589
|
1589
|
UPDATE organization set is_join='0' WHERE is_join is null;
|
1590
|
1590
|
ALTER TABLE organization ALTER COLUMN is_join SET NOT NULL;
|
1591
|
1591
|
|
1592
|
|
|
|
1592
|
drop view view_user_count;
|
|
1593
|
drop view view_user_pictable;
|
|
1594
|
drop view view_allcustomer;
|
|
1595
|
drop view view_customer;
|
|
1596
|
drop view view_my_customer;
|
|
1597
|
ALTER TABLE professor ALTER COLUMN phone TYPE varchar(50);
|
|
1598
|
|
|
1599
|
CREATE OR REPLACE VIEW view_allcustomer AS
|
|
1600
|
SELECT professor.id,professor.email,professor.phone,luser.mobile_phone,luser.create_time,luser.active_time,
|
|
1601
|
luser.send_mail_status,luser.invite_code,luser.inviter_id,luser.user_type,professor.subject,professor.industry,
|
|
1602
|
professor.department,professor.office,professor.org_id,professor.title,professor.name,professor.address,
|
|
1603
|
professor.authentication,professor.auth_type,professor.auth_status,professor.sort_first,professor.auth_status_expert,
|
|
1604
|
organization.name AS orgname
|
|
1605
|
FROM ((luser RIGHT JOIN professor ON ((luser.id = professor.id)))
|
|
1606
|
LEFT JOIN organization ON ((professor.org_id = organization.id)));;
|
|
1607
|
CREATE OR REPLACE VIEW view_customer AS
|
|
1608
|
SELECT professor.id,professor.email,professor.phone,luser.mobile_phone,luser.create_time,luser.active_time,luser.send_mail_status,
|
|
1609
|
luser.invite_code,luser.inviter_id,luser.user_type,professor.subject,professor.industry,professor.department,professor.office,
|
|
1610
|
professor.org_id,professor.title,professor.name,professor.address,professor.authentication,professor.auth_type,professor.auth_status,
|
|
1611
|
professor.sort_first,professor.auth_status_expert,organization.name AS orgname
|
|
1612
|
FROM ((luser
|
|
1613
|
RIGHT JOIN professor ON ((luser.id = professor.id)))
|
|
1614
|
LEFT JOIN organization ON ((professor.org_id = organization.id)))
|
|
1615
|
WHERE (((luser.inviter_id IS NULL) OR (luser.active_time IS NULL)) AND (NOT (EXISTS ( SELECT customer_power.professor_id
|
|
1616
|
FROM customer_power
|
|
1617
|
WHERE ((customer_power.professor_id = luser.id) AND ((customer_power.pow_type = '0'::bpchar) OR (customer_power.pow_type = '1'::bpchar)))))));;
|
|
1618
|
|
|
1619
|
CREATE OR REPLACE VIEW view_my_customer AS
|
|
1620
|
SELECT customer_power.power_id,professor.id,professor.email,professor.subject,professor.industry,professor.department,professor.office,professor.org_id,
|
|
1621
|
professor.title,professor.name,professor.address,professor.authentication,professor.auth_type,professor.auth_status,professor.sort_first,professor.auth_status_expert,
|
|
1622
|
organization.name AS orgname,customer_power.descp,customer_power.create_time,customer_power.pow_type,customer_power.modify_time,customer_power.cuser_id,
|
|
1623
|
luser.mobile_phone AS phone,cuser.name AS cuser_name,luser.invite_code
|
|
1624
|
FROM ((((customer_power
|
|
1625
|
JOIN professor ON ((customer_power.professor_id = professor.id)))
|
|
1626
|
JOIN organization ON ((professor.org_id = organization.id)))
|
|
1627
|
JOIN luser ON ((professor.id = luser.id)))
|
|
1628
|
JOIN cuser ON ((customer_power.cuser_id = cuser.id)));;
|
|
1629
|
|
|
1630
|
CREATE OR REPLACE VIEW view_user_count AS
|
|
1631
|
SELECT to_date(cc.create_time, 'yyyymmdd'::text) AS create_time,
|
|
1632
|
COALESCE(znum.num, (0)::bigint) AS znum,
|
|
1633
|
COALESCE(jnum.jnum, (0)::bigint) AS jnum,
|
|
1634
|
dn.ljnum,
|
|
1635
|
dn.lznum
|
|
1636
|
FROM (((( SELECT to_char(generate_series((date_trunc('month'::text, now()) - '1 mon'::interval), now(), '1 day'::interval), 'yyyymmdd'::text) AS create_time) cc
|
|
1637
|
LEFT JOIN ( SELECT num.create_time,count(num.id) AS num
|
|
1638
|
FROM ( SELECT luser.id,
|
|
1639
|
"substring"((luser.create_time)::text, 1, 8) AS create_time
|
|
1640
|
FROM luser
|
|
1641
|
WHERE (to_date((luser.create_time)::text, 'YYYYMMDDHH24MISS'::text) >= (now() - '30 days'::interval))) num
|
|
1642
|
GROUP BY num.create_time) znum ON ((cc.create_time = znum.create_time)))
|
|
1643
|
LEFT JOIN ( SELECT num1.create_time,
|
|
1644
|
count(num1.id) AS jnum
|
|
1645
|
FROM ( SELECT luser.id,
|
|
1646
|
"substring"((luser.active_time)::text, 1, 8) AS create_time
|
|
1647
|
FROM luser
|
|
1648
|
WHERE (to_date((luser.active_time)::text, 'YYYYMMDDHH24MISS'::text) >= (now() - '30 days'::interval))) num1
|
|
1649
|
GROUP BY num1.create_time) jnum ON ((cc.create_time = jnum.create_time)))
|
|
1650
|
LEFT JOIN ( SELECT d1.create_time,
|
|
1651
|
0 AS num,
|
|
1652
|
0 AS jnum,
|
|
1653
|
d1.ljnum,
|
|
1654
|
d1.lznum
|
|
1655
|
FROM ( SELECT lj1.create_time,
|
|
1656
|
sum(lj1.ljnum) AS ljnum,
|
|
1657
|
sum(lj1.lznum) AS lznum
|
|
1658
|
FROM ( SELECT to_char(now(), 'YYYYMMDD'::text) AS create_time,
|
|
1659
|
0 AS ljnum,
|
|
1660
|
count(luser.id) AS lznum
|
|
1661
|
FROM luser
|
|
1662
|
WHERE ("substring"((luser.create_time)::text, 1, 8) <= to_char(now(), 'YYYYMMDD'::text))
|
|
1663
|
UNION
|
|
1664
|
SELECT to_char(now(), 'YYYYMMDD'::text) AS create_time,
|
|
1665
|
count(luser.id) AS ljnum,
|
|
1666
|
0 AS lznum
|
|
1667
|
FROM luser
|
|
1668
|
WHERE ("substring"((luser.active_time)::text, 1, 8) <= to_char(now(), 'YYYYMMDD'::text))) lj1
|
|
1669
|
GROUP BY lj1.create_time
|
|
1670
|
UNION
|
|
1671
|
SELECT lj1.create_time,
|
|
1672
|
sum(lj1.ljnum) AS ljnum,
|
|
1673
|
sum(lj1.lznum) AS lznum
|
|
1674
|
FROM ( SELECT to_char((('now'::text)::date - '1 day'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1675
|
0 AS ljnum,
|
|
1676
|
count(luser.id) AS lznum
|
|
1677
|
FROM luser
|
|
1678
|
WHERE ("substring"((luser.create_time)::text, 1, 8) <= to_char((('now'::text)::date - '1 day'::interval), 'YYYYMMDD'::text))
|
|
1679
|
UNION
|
|
1680
|
SELECT to_char((('now'::text)::date - '1 day'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1681
|
count(luser.id) AS ljnum,
|
|
1682
|
0 AS lznum
|
|
1683
|
FROM luser
|
|
1684
|
WHERE ("substring"((luser.active_time)::text, 1, 8) <= to_char((('now'::text)::date - '1 day'::interval), 'YYYYMMDD'::text))) lj1
|
|
1685
|
GROUP BY lj1.create_time
|
|
1686
|
UNION
|
|
1687
|
SELECT lj1.create_time,
|
|
1688
|
sum(lj1.ljnum) AS ljnum,
|
|
1689
|
sum(lj1.lznum) AS lznum
|
|
1690
|
FROM ( SELECT to_char((('now'::text)::date - '2 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1691
|
0 AS ljnum,
|
|
1692
|
count(luser.id) AS lznum
|
|
1693
|
FROM luser
|
|
1694
|
WHERE ("substring"((luser.create_time)::text, 1, 8) <= to_char((('now'::text)::date - '2 days'::interval), 'YYYYMMDD'::text))
|
|
1695
|
UNION
|
|
1696
|
SELECT to_char((('now'::text)::date - '2 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1697
|
count(luser.id) AS ljnum,
|
|
1698
|
0 AS lznum
|
|
1699
|
FROM luser
|
|
1700
|
WHERE ("substring"((luser.active_time)::text, 1, 8) <= to_char((('now'::text)::date - '2 days'::interval), 'YYYYMMDD'::text))) lj1
|
|
1701
|
GROUP BY lj1.create_time
|
|
1702
|
UNION
|
|
1703
|
SELECT lj1.create_time,
|
|
1704
|
sum(lj1.ljnum) AS ljnum,
|
|
1705
|
sum(lj1.lznum) AS lznum
|
|
1706
|
FROM ( SELECT to_char((('now'::text)::date - '3 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1707
|
0 AS ljnum,
|
|
1708
|
count(luser.id) AS lznum
|
|
1709
|
FROM luser
|
|
1710
|
WHERE ("substring"((luser.create_time)::text, 1, 8) <= to_char((('now'::text)::date - '3 days'::interval), 'YYYYMMDD'::text))
|
|
1711
|
UNION
|
|
1712
|
SELECT to_char((('now'::text)::date - '3 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1713
|
count(luser.id) AS ljnum,
|
|
1714
|
0 AS lznum
|
|
1715
|
FROM luser
|
|
1716
|
WHERE ("substring"((luser.active_time)::text, 1, 8) <= to_char((('now'::text)::date - '3 days'::interval), 'YYYYMMDD'::text))) lj1
|
|
1717
|
GROUP BY lj1.create_time
|
|
1718
|
UNION
|
|
1719
|
SELECT lj1.create_time,
|
|
1720
|
sum(lj1.ljnum) AS ljnum,
|
|
1721
|
sum(lj1.lznum) AS lznum
|
|
1722
|
FROM ( SELECT to_char((('now'::text)::date - '4 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1723
|
0 AS ljnum,
|
|
1724
|
count(luser.id) AS lznum
|
|
1725
|
FROM luser
|
|
1726
|
WHERE ("substring"((luser.create_time)::text, 1, 8) <= to_char((('now'::text)::date - '4 days'::interval), 'YYYYMMDD'::text))
|
|
1727
|
UNION
|
|
1728
|
SELECT to_char((('now'::text)::date - '4 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1729
|
count(luser.id) AS ljnum,
|
|
1730
|
0 AS lznum
|
|
1731
|
FROM luser
|
|
1732
|
WHERE ("substring"((luser.active_time)::text, 1, 8) <= to_char((('now'::text)::date - '4 days'::interval), 'YYYYMMDD'::text))) lj1
|
|
1733
|
GROUP BY lj1.create_time
|
|
1734
|
UNION
|
|
1735
|
SELECT lj1.create_time,
|
|
1736
|
sum(lj1.ljnum) AS ljnum,
|
|
1737
|
sum(lj1.lznum) AS lznum
|
|
1738
|
FROM ( SELECT to_char((('now'::text)::date - '5 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1739
|
0 AS ljnum,
|
|
1740
|
count(luser.id) AS lznum
|
|
1741
|
FROM luser
|
|
1742
|
WHERE ("substring"((luser.create_time)::text, 1, 8) <= to_char((('now'::text)::date - '5 days'::interval), 'YYYYMMDD'::text))
|
|
1743
|
UNION
|
|
1744
|
SELECT to_char((('now'::text)::date - '5 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1745
|
count(luser.id) AS ljnum,
|
|
1746
|
0 AS lznum
|
|
1747
|
FROM luser
|
|
1748
|
WHERE ("substring"((luser.active_time)::text, 1, 8) <= to_char((('now'::text)::date - '5 days'::interval), 'YYYYMMDD'::text))) lj1
|
|
1749
|
GROUP BY lj1.create_time
|
|
1750
|
UNION
|
|
1751
|
SELECT lj1.create_time,
|
|
1752
|
sum(lj1.ljnum) AS ljnum,
|
|
1753
|
sum(lj1.lznum) AS lznum
|
|
1754
|
FROM ( SELECT to_char((('now'::text)::date - '6 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1755
|
0 AS ljnum,
|
|
1756
|
count(luser.id) AS lznum
|
|
1757
|
FROM luser
|
|
1758
|
WHERE ("substring"((luser.create_time)::text, 1, 8) <= to_char((('now'::text)::date - '6 days'::interval), 'YYYYMMDD'::text))
|
|
1759
|
UNION
|
|
1760
|
SELECT to_char((('now'::text)::date - '6 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1761
|
count(luser.id) AS ljnum,
|
|
1762
|
0 AS lznum
|
|
1763
|
FROM luser
|
|
1764
|
WHERE ("substring"((luser.active_time)::text, 1, 8) <= to_char((('now'::text)::date - '6 days'::interval), 'YYYYMMDD'::text))) lj1
|
|
1765
|
GROUP BY lj1.create_time) d1) dn ON ((cc.create_time = dn.create_time)));;
|
|
1766
|
|
|
1767
|
CREATE OR REPLACE VIEW view_user_pictable AS
|
|
1768
|
SELECT dn.create_time,
|
|
1769
|
dn.cuser_id,
|
|
1770
|
sum(dn.znum) AS znum, sum(dn.jnum) AS jnum,
|
|
1771
|
sum(dn.ljnum) AS ljnum,
|
|
1772
|
sum(dn.lznum) AS lznum
|
|
1773
|
FROM ( SELECT to_date(u.create_time, 'YYYYMMDD'::text) AS create_time,
|
|
1774
|
u.cuser_id,
|
|
1775
|
0 AS znum,
|
|
1776
|
0 AS jnum,
|
|
1777
|
0 AS ljnum,
|
|
1778
|
0 AS lznum
|
|
1779
|
FROM ( SELECT to_char(now(), 'YYYYMMDD'::text) AS create_time,
|
|
1780
|
cuser.id AS cuser_id
|
|
1781
|
FROM cuser
|
|
1782
|
UNION
|
|
1783
|
SELECT to_char((('now'::text)::date - '1 day'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1784
|
cuser.id AS cuser_id
|
|
1785
|
FROM cuser
|
|
1786
|
UNION
|
|
1787
|
SELECT to_char((('now'::text)::date - '2 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1788
|
cuser.id AS cuser_id
|
|
1789
|
FROM cuser
|
|
1790
|
UNION
|
|
1791
|
SELECT to_char((('now'::text)::date - '3 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1792
|
cuser.id AS cuser_id
|
|
1793
|
FROM cuser
|
|
1794
|
UNION
|
|
1795
|
SELECT to_char((('now'::text)::date - '4 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1796
|
cuser.id AS cuser_id
|
|
1797
|
FROM cuser
|
|
1798
|
UNION
|
|
1799
|
SELECT to_char((('now'::text)::date - '5 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1800
|
cuser.id AS cuser_id
|
|
1801
|
FROM cuser
|
|
1802
|
UNION
|
|
1803
|
SELECT to_char((('now'::text)::date - '6 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1804
|
cuser.id AS cuser_id
|
|
1805
|
FROM cuser) u
|
|
1806
|
UNION
|
|
1807
|
SELECT to_date(n1.create_time, 'YYYYMMDD'::text) AS create_time,
|
|
1808
|
n1.cuser_id,
|
|
1809
|
n1.znum,
|
|
1810
|
0 AS jnum,
|
|
1811
|
(0)::numeric AS ljnum,
|
|
1812
|
(0)::numeric AS lznum
|
|
1813
|
FROM ( SELECT "substring"((view_my_customer.create_time)::text, 1, 8) AS create_time,
|
|
1814
|
view_my_customer.cuser_id,
|
|
1815
|
count(view_my_customer.power_id) AS znum
|
|
1816
|
FROM view_my_customer
|
|
1817
|
WHERE (to_date((view_my_customer.create_time)::text, 'YYYYMMDDHH24MISS'::text) >= (('now'::text)::date - '6 days'::interval))
|
|
1818
|
GROUP BY "substring"((view_my_customer.create_time)::text, 1, 8), view_my_customer.cuser_id) n1
|
|
1819
|
UNION
|
|
1820
|
SELECT to_date(j1.create_time, 'YYYYMMDD'::text) AS create_time,
|
|
1821
|
j1.cuser_id,
|
|
1822
|
0 AS znum,
|
|
1823
|
j1.jnum,
|
|
1824
|
(0)::numeric AS ljnum,
|
|
1825
|
(0)::numeric AS lznum
|
|
1826
|
FROM ( SELECT "substring"((view_my_customer.create_time)::text, 1, 8) AS create_time,
|
|
1827
|
view_my_customer.cuser_id,
|
|
1828
|
count(view_my_customer.power_id) AS jnum
|
|
1829
|
FROM view_my_customer
|
|
1830
|
WHERE ((to_date((view_my_customer.create_time)::text, 'YYYYMMDDHH24MISS'::text) >= (('now'::text)::date - '6 days'::interval)) AND (view_my_customer.pow_type = '1'::bpchar))
|
|
1831
|
GROUP BY "substring"((view_my_customer.create_time)::text, 1, 8), view_my_customer.cuser_id) j1
|
|
1832
|
UNION
|
|
1833
|
SELECT to_date(d1.create_time, 'YYYYMMDD'::text) AS create_time,
|
|
1834
|
d1.cuser_id,
|
|
1835
|
0 AS znum,
|
|
1836
|
0 AS jnum,
|
|
1837
|
d1.ljnum,
|
|
1838
|
d1.lznum
|
|
1839
|
FROM ( SELECT lj1.create_time,
|
|
1840
|
lj1.cuser_id,
|
|
1841
|
sum(lj1.ljnum) AS ljnum,
|
|
1842
|
sum(lj1.lznum) AS lznum
|
|
1843
|
FROM ( SELECT to_char(now(), 'YYYYMMDD'::text) AS create_time,
|
|
1844
|
view_my_customer.cuser_id,
|
|
1845
|
0 AS ljnum,
|
|
1846
|
count(view_my_customer.power_id) AS lznum
|
|
1847
|
FROM view_my_customer
|
|
1848
|
WHERE ("substring"((view_my_customer.create_time)::text, 1, 8) <= to_char(now(), 'YYYYMMDD'::text))
|
|
1849
|
GROUP BY view_my_customer.cuser_id
|
|
1850
|
UNION
|
|
1851
|
SELECT to_char(now(), 'YYYYMMDD'::text) AS create_time,
|
|
1852
|
view_my_customer.cuser_id,
|
|
1853
|
count(view_my_customer.power_id) AS ljnum,
|
|
1854
|
0 AS lznum
|
|
1855
|
FROM view_my_customer
|
|
1856
|
WHERE (("substring"((view_my_customer.create_time)::text, 1, 8) <= to_char(now(), 'YYYYMMDD'::text)) AND (view_my_customer.pow_type = '1'::bpchar))
|
|
1857
|
GROUP BY view_my_customer.cuser_id) lj1
|
|
1858
|
GROUP BY lj1.create_time, lj1.cuser_id
|
|
1859
|
UNION
|
|
1860
|
SELECT lj2.create_time,
|
|
1861
|
lj2.cuser_id,
|
|
1862
|
sum(lj2.ljnum) AS ljnum,
|
|
1863
|
sum(lj2.lznum) AS lznum
|
|
1864
|
FROM ( SELECT to_char((('now'::text)::date - '1 day'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1865
|
view_my_customer.cuser_id,
|
|
1866
|
0 AS ljnum,
|
|
1867
|
count(view_my_customer.power_id) AS lznum
|
|
1868
|
FROM view_my_customer
|
|
1869
|
WHERE ("substring"((view_my_customer.create_time)::text, 1, 8) <= to_char((('now'::text)::date - '1 day'::interval), 'YYYYMMDD'::text))
|
|
1870
|
GROUP BY view_my_customer.cuser_id
|
|
1871
|
UNION
|
|
1872
|
SELECT to_char((('now'::text)::date - '1 day'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1873
|
view_my_customer.cuser_id,
|
|
1874
|
count(view_my_customer.power_id) AS ljnum,
|
|
1875
|
0 AS lznum
|
|
1876
|
FROM view_my_customer
|
|
1877
|
WHERE (("substring"((view_my_customer.create_time)::text, 1, 8) <= to_char((('now'::text)::date - '1 day'::interval), 'YYYYMMDD'::text)) AND (view_my_customer.pow_type = '1'::bpchar))
|
|
1878
|
GROUP BY view_my_customer.cuser_id) lj2
|
|
1879
|
GROUP BY lj2.create_time, lj2.cuser_id
|
|
1880
|
UNION
|
|
1881
|
SELECT lj3.create_time,
|
|
1882
|
lj3.cuser_id,
|
|
1883
|
sum(lj3.ljnum) AS ljnum,
|
|
1884
|
sum(lj3.lznum) AS lznum
|
|
1885
|
FROM ( SELECT to_char((('now'::text)::date - '2 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1886
|
view_my_customer.cuser_id,
|
|
1887
|
0 AS ljnum,
|
|
1888
|
count(view_my_customer.power_id) AS lznum
|
|
1889
|
FROM view_my_customer
|
|
1890
|
WHERE ("substring"((view_my_customer.create_time)::text, 1, 8) <= to_char((('now'::text)::date - '2 days'::interval), 'YYYYMMDD'::text))
|
|
1891
|
GROUP BY view_my_customer.cuser_id
|
|
1892
|
UNION
|
|
1893
|
SELECT to_char((('now'::text)::date - '2 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1894
|
view_my_customer.cuser_id,
|
|
1895
|
count(view_my_customer.power_id) AS ljnum,
|
|
1896
|
0 AS lznum
|
|
1897
|
FROM view_my_customer
|
|
1898
|
WHERE (("substring"((view_my_customer.create_time)::text, 1, 8) <= to_char((('now'::text)::date - '2 days'::interval), 'YYYYMMDD'::text)) AND (view_my_customer.pow_type = '1'::bpchar))
|
|
1899
|
GROUP BY view_my_customer.cuser_id) lj3
|
|
1900
|
GROUP BY lj3.create_time, lj3.cuser_id
|
|
1901
|
UNION
|
|
1902
|
SELECT lj4.create_time,
|
|
1903
|
lj4.cuser_id,
|
|
1904
|
sum(lj4.ljnum) AS ljnum,
|
|
1905
|
sum(lj4.lznum) AS lznum
|
|
1906
|
FROM ( SELECT to_char((('now'::text)::date - '3 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1907
|
view_my_customer.cuser_id,
|
|
1908
|
0 AS ljnum,
|
|
1909
|
count(view_my_customer.power_id) AS lznum
|
|
1910
|
FROM view_my_customer
|
|
1911
|
WHERE ("substring"((view_my_customer.create_time)::text, 1, 8) <= to_char((('now'::text)::date - '3 days'::interval), 'YYYYMMDD'::text))
|
|
1912
|
GROUP BY view_my_customer.cuser_id
|
|
1913
|
UNION
|
|
1914
|
SELECT to_char((('now'::text)::date - '3 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1915
|
view_my_customer.cuser_id,
|
|
1916
|
count(view_my_customer.power_id) AS ljnum,
|
|
1917
|
0 AS lznum
|
|
1918
|
FROM view_my_customer
|
|
1919
|
WHERE (("substring"((view_my_customer.create_time)::text, 1, 8) <= to_char((('now'::text)::date - '3 days'::interval), 'YYYYMMDD'::text)) AND (view_my_customer.pow_type = '1'::bpchar))
|
|
1920
|
GROUP BY view_my_customer.cuser_id) lj4
|
|
1921
|
GROUP BY lj4.create_time, lj4.cuser_id
|
|
1922
|
UNION
|
|
1923
|
SELECT lj5.create_time,
|
|
1924
|
lj5.cuser_id,
|
|
1925
|
sum(lj5.ljnum) AS ljnum,
|
|
1926
|
sum(lj5.lznum) AS lznum
|
|
1927
|
FROM ( SELECT to_char((('now'::text)::date - '4 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1928
|
view_my_customer.cuser_id,
|
|
1929
|
0 AS ljnum,
|
|
1930
|
count(view_my_customer.power_id) AS lznum
|
|
1931
|
FROM view_my_customer
|
|
1932
|
WHERE ("substring"((view_my_customer.create_time)::text, 1, 8) <= to_char((('now'::text)::date - '4 days'::interval), 'YYYYMMDD'::text))
|
|
1933
|
GROUP BY view_my_customer.cuser_id
|
|
1934
|
UNION
|
|
1935
|
SELECT to_char((('now'::text)::date - '4 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1936
|
view_my_customer.cuser_id,
|
|
1937
|
count(view_my_customer.power_id) AS ljnum,
|
|
1938
|
0 AS lznum
|
|
1939
|
FROM view_my_customer
|
|
1940
|
WHERE (("substring"((view_my_customer.create_time)::text, 1, 8) <= to_char((('now'::text)::date - '4 days'::interval), 'YYYYMMDD'::text)) AND (view_my_customer.pow_type = '1'::bpchar))
|
|
1941
|
GROUP BY view_my_customer.cuser_id) lj5
|
|
1942
|
GROUP BY lj5.create_time, lj5.cuser_id
|
|
1943
|
UNION
|
|
1944
|
SELECT lj6.create_time,
|
|
1945
|
lj6.cuser_id,
|
|
1946
|
sum(lj6.ljnum) AS ljnum,
|
|
1947
|
sum(lj6.lznum) AS lznum
|
|
1948
|
FROM ( SELECT to_char((('now'::text)::date - '5 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1949
|
view_my_customer.cuser_id,
|
|
1950
|
0 AS ljnum,
|
|
1951
|
count(view_my_customer.power_id) AS lznum
|
|
1952
|
FROM view_my_customer
|
|
1953
|
WHERE ("substring"((view_my_customer.create_time)::text, 1, 8) <= to_char((('now'::text)::date - '5 days'::interval), 'YYYYMMDD'::text))
|
|
1954
|
GROUP BY view_my_customer.cuser_id
|
|
1955
|
UNION
|
|
1956
|
SELECT to_char((('now'::text)::date - '5 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1957
|
view_my_customer.cuser_id,
|
|
1958
|
count(view_my_customer.power_id) AS ljnum,
|
|
1959
|
0 AS lznum
|
|
1960
|
FROM view_my_customer
|
|
1961
|
WHERE (("substring"((view_my_customer.create_time)::text, 1, 8) <= to_char((('now'::text)::date - '5 days'::interval), 'YYYYMMDD'::text)) AND (view_my_customer.pow_type = '1'::bpchar))
|
|
1962
|
GROUP BY view_my_customer.cuser_id) lj6
|
|
1963
|
GROUP BY lj6.create_time, lj6.cuser_id
|
|
1964
|
UNION
|
|
1965
|
SELECT lj7.create_time,
|
|
1966
|
lj7.cuser_id,
|
|
1967
|
sum(lj7.ljnum) AS ljnum,
|
|
1968
|
sum(lj7.lznum) AS lznum
|
|
1969
|
FROM ( SELECT to_char((('now'::text)::date - '6 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1970
|
view_my_customer.cuser_id,
|
|
1971
|
0 AS ljnum,
|
|
1972
|
count(view_my_customer.power_id) AS lznum
|
|
1973
|
FROM view_my_customer
|
|
1974
|
WHERE ("substring"((view_my_customer.create_time)::text, 1, 8) <= to_char((('now'::text)::date - '6 days'::interval), 'YYYYMMDD'::text))
|
|
1975
|
GROUP BY view_my_customer.cuser_id
|
|
1976
|
UNION
|
|
1977
|
SELECT to_char((('now'::text)::date - '6 days'::interval), 'YYYYMMDD'::text) AS create_time,
|
|
1978
|
view_my_customer.cuser_id,
|
|
1979
|
count(view_my_customer.power_id) AS ljnum,
|
|
1980
|
0 AS lznum
|
|
1981
|
FROM view_my_customer
|
|
1982
|
WHERE (("substring"((view_my_customer.create_time)::text, 1, 8) <= to_char((('now'::text)::date - '6 days'::interval), 'YYYYMMDD'::text)) AND (view_my_customer.pow_type = '1'::bpchar))
|
|
1983
|
GROUP BY view_my_customer.cuser_id) lj7
|
|
1984
|
GROUP BY lj7.create_time, lj7.cuser_id) d1) dn
|
|
1985
|
GROUP BY dn.create_time, dn.cuser_id
|
|
1986
|
ORDER BY dn.create_time;;
|
1593
|
1987
|
|
1594
|
1988
|
|
1595
|
1989
|
|