Good afternoon, I am on a 7.1 iseries using command line STRSQL
I am trying to read an 8,0 field in YYYYMMDD format with a case statement to group them by month going across.
This is what I have so far against one month, FRCVR# is the customer number.
SELECT FRCVR# , frcdat,
case
when frcdat between 20160101 and 20160131
then count(*) else 0 end as jancount,
FROM FRTxxxx/FRIxxxx
where
frcvr# IN(50190,17993,91736,89580) and frcdat between
20160101 and 20160331
group by FRCVR#
order by FRCVR#
I saw information online regarding a DATE format to see if I could just get a grouping that way, but get message "Column or global variable DATE not found"
When I change DATE to my date field I get the message "Argument 1 of function MONTH not valid"
select frcvr#, MONTH(DATE) As "Month"
FROM FRTxxxx/FRIxxxx
where
frcvr# IN(50190,17993,91736,89580) and frcdat between
20170101 and 20170331
group by FRCVR#, MONTH(DATE)
order by FRCVR#, MONTH(DATE)
I would want to expand it out to 12 months if I can get this to work. Any help would be appreciated.
thank you
I am trying to read an 8,0 field in YYYYMMDD format with a case statement to group them by month going across.
This is what I have so far against one month, FRCVR# is the customer number.
SELECT FRCVR# , frcdat,
case
when frcdat between 20160101 and 20160131
then count(*) else 0 end as jancount,
FROM FRTxxxx/FRIxxxx
where
frcvr# IN(50190,17993,91736,89580) and frcdat between
20160101 and 20160331
group by FRCVR#
order by FRCVR#
I saw information online regarding a DATE format to see if I could just get a grouping that way, but get message "Column or global variable DATE not found"
When I change DATE to my date field I get the message "Argument 1 of function MONTH not valid"
select frcvr#, MONTH(DATE) As "Month"
FROM FRTxxxx/FRIxxxx
where
frcvr# IN(50190,17993,91736,89580) and frcdat between
20170101 and 20170331
group by FRCVR#, MONTH(DATE)
order by FRCVR#, MONTH(DATE)
I would want to expand it out to 12 months if I can get this to work. Any help would be appreciated.
thank you
Comment