0

I'm trying to set up a query that will create a simple report that will show a data range over a two week period whether a cron job was scheduled or not. I have two tables and sample data available here that I was using try and figure out a way to display the results. I have an example of a way that would work to display the data, except I have no clue how to get it to work.

Normally I would post the code that I was using to try and make something work, I honestly don't even know where to start. Maybe it's not possible, but I think it is.

Thanks in advance!

Realto619
  • 301
  • 3
  • 13

1 Answers1

1

As pointed out in the comments, this requires a pivot table and a possible duplicate is found at here

The following is based on this answer https://stackoverflow.com/a/26968969/3854195

SELECT cronDate
    , COUNT(cronJobCD=1 AND cronStatus=1 OR NULL) AS BV_Conn
    , COUNT(cronJobCD=2 AND cronStatus=1 OR NULL) AS BV_Conn2
    , COUNT(cronJobCD=3 AND cronStatus=1 OR NULL) AS ConvPro
    , COUNT(cronJobCD=4 AND cronStatus=1 OR NULL) AS SalesPerson
    , COUNT(cronJobCD=5 AND cronStatus=1 OR NULL) AS NS_BV
    , COUNT(cronJobCD=6 AND cronStatus=1 OR NULL) AS NS_Feeds
FROM 
    cronStatus S
GROUP BY 
    cronDate
Community
  • 1
  • 1
Morpheus
  • 1,616
  • 1
  • 21
  • 31