Solved

Like

Posted on 2008-10-13
4
136 Views
Last Modified: 2010-04-21
I have a  pivot query, which is;

SELECT     AttendanceDate, [C100] AS C1, [C200] AS C2
FROM         (SELECT     AttendanceDate, Derived_Provider
                       FROM          OPA_General
                       WHERE      (AttendanceDate BETWEEN CONVERT(DATETIME, '03 /01/ 2007 00:00:00', 103) AND CONVERT(DATETIME, '05/03/2007 00:00:00', 103)))
                      p PIVOT (COUNT(Deriverd_Provider) FOR Derived_Provider IN (C100, C200)) AS pvt
ORDER BY AttendanceDate

I would like to change the IN clause to pick up values which are LIKE C100. This also means I will have to change the first select clause to pick up variations of C100. I am not sure how to do either of these tasks.
0
Comment
Question by:Mr_Shaw
  • 2
  • 2
4 Comments
 
LVL 60

Accepted Solution

by:
chapmandew earned 500 total points
ID: 22701625
unfortunately, with a PIVOT you have to know the values for while you're going to pivot.
0
 

Author Comment

by:Mr_Shaw
ID: 22701645
I have previously tried to do the same thing with a case statements, but never achieved it. Do yoyu know how to use Case to act like a pivot
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 22701779
sure:

select --do some sort of aggregations here
from
(
select
case1 = case when fieldvalue = 1 then 'somevalue' else 0 end,
case2 = case when fieldvalue = 1 then 'somevalue' else 0 end,
case3 = case when fieldvalue = 1 then 'somevalue' else 0 end,
case4 = case when fieldvalue = 1 then 'somevalue' else 0 end
from table
) a
group by....
0
 

Author Closing Comment

by:Mr_Shaw
ID: 31406258
Thanks,
Better to know that I can't do it than try for hours in vain...
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now