Link to home
Start Free TrialLog in
Avatar of CaptainGiblets
CaptainGibletsFlag for United Kingdom of Great Britain and Northern Ireland

asked on

SQL Pivot Table

I have data that has 2 columns, a status and a date.

is it possible to build the following report in SQL and if so how would I do it

                  Today         Yesterday           Week             Month
StatusA
StatusB

So I would want a total sent today from statusA and B then yesterdays everything this week and finally everything this month (last 7 and 30 days)
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

So, count of all StatusAs for today, count of all from yesterday, etc?
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CaptainGiblets

ASKER

That works a treat, just a quick question before I close it off, if I wanted to use a different date field for 2 different statuses is this possible? From what I know I would have to create 2 different views with the different date field but just thought I would throw it out there.

For example 2 status  "Sent Out" and "Returned"  with 2 dates "date Sent Out" and "Date Returned"
Sounds to me that that approach could be extended to additional date columns...