Subject | Grouping SQL counts |
---|---|
Author | |
Post date | 2014-12-11T00:47:04Z |
FB 1.5x
I have a SQL statement that returns the results I want--giving me a count on the detail dataset
(ClientRegHistList is a detail list on ClientRegHis, more info below)
select C.RegDate, Count(Client_ID)
from ClientRegHist C,
ClientReghistList CL
where (CL.ClientRegHist_ID = C.ClientRegHist_ID)
and CL.RegType = 0
and (C.Company_ID = 128)
group by 1;
I have a second SQL that is exactly the same except changing the "0" to a "1" in line 5. I would like to combine the two datasets into one result set--any hints on how to do this?
Thank you,
Ed Dressel
CREATE TABLE CLIENTREGHIST (
CLIENTREGHIST_ID DM_KEY /* DM_KEY = INTEGER NOT NULL */,
REGDATE DM_DATE /* DM_DATE = TIMESTAMP */,
COMPANY_ID DM_INTEGER /* DM_INTEGER = INTEGER */
);
CREATE TABLE CLIENTREGHISTLIST (
CLIENTREGHIST_ID DM_INTEGER /* DM_INTEGER = INTEGER */,
REGTYPE DM_INTEGER /* DM_INTEGER = INTEGER */,
CLIENT_ID DM_INTEGER /* DM_INTEGER = INTEGER */
);
ALTER TABLE CLIENTREGHISTLIST ADD CONSTRAINT FK_CLIENTREGHISTLIST_1 FOREIGN KEY (CLIENTREGHIST_ID) REFERENCES CLIENTREGHIST (CLIENTREGHIST_ID) ON DELETE CASCADE;
ALTER TABLE CLIENTREGHISTLIST ADD CONSTRAINT FK_CLIENTREGHISTLIST_2 FOREIGN KEY (CLIENT_ID) REFERENCES CLIENTINFO (CLIENT_ID);