문제

I am having table DEMO

CUST_ID    DATE_ENQ
---------- ---------
30         28-APR-14 
31         27-APR-14 
30         27-APR-14 

I want output something like this

COUNT(CUST_ID) DATE_ENQ
-------------- ---------
             2 27-APR-14 
             1 28-APR-14 

도움이 되었습니까?

해결책

Try Thiz

select count(CUST_ID),TO_CHAR(DATE_ENQ,'DD-MON-YYYY') from demo group by TO_CHAR(DATE_ENQ,'DD-MON-YYYY');

SQL Fiddle Demo Click Here

다른 팁

DELETE FROM
   DEMO D1
WHERE
  D1.rowid >
   ANY (
     SELECT
        D2.rowid
     FROM
        DEMO D2
     WHERE
        D1.CUST_ID = D2.CUST_ID
        );

Please try:

SELECT 
  *
FROM tbl
WHERE rowid in
  (SELECT MIN(rowid)
  FROM tbl
  GROUP BY DATE_ENQ);

SQL Fiddle Demo

Try this -

select cust_id, min(date_enq) as Datez, COUNT(cust_id) as Custs
from tbl
group by cust_id

You will get the output as you have mentioned above. I have checked This is working

SELECT count(CUST_ID), DATE_ENQ FROM Demo GROUP BY DATE_ENQ;

Thanks and Regards

SELECT COUNT(*) as TotalCustomers,DATE_ENQ
FROM tableName
GROUP BY DATE_ENQ
ORDER BY TotalCustomers
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top