February 18, 2009 at 8:22 am
I have 2 projects requiring assistance with set up of an SQL view to capture crosstab data
Project#1
fields include giftkey(numeric), gifthonorcode(char)
table name is giving
Objective is to display the giftkey once and up to four instances of their gifthonorcode on the same row/column. I assume I would use a case statement with a max function
Project#2
fields include memberkey(numeric), memberdate(date/time), renewaldate(date/time)
table name is membership
Objective is to display the memberkey once and up to 5 instances of a memberdate and renewal date for on the same row/column. The goal is to produce a percentage of records that renew membership.
I have tried using the max function but I believe I am missing something. I could use a basic script that I can use in a view. Will I also need a stored procedure?
February 18, 2009 at 9:27 am
Please show some code here. It sounds as though this is a homework question, and while we're happy to help, we don't want to do the work for you. Show us what you've done and what isn't working (with sample data or result sets) and we'll help.
Also, please post in the appropriate forum. Moved to T-SQL forum.
February 18, 2009 at 9:38 am
Project#1
select a.giftkey,a.giftid,a.gifthonor, b.gifthnrkey,b.giftid,b.gifthonor
from gifts a left outer join dbo.gifts b
on a.giftid = b.giftid
where a.gifthonor is not null
It simply repeats data. I am trying to list a.giftkey once then every instance of the gifthonor
Here is an example of what I want
a.giftkey a.giftid b.gifthnrkey b.giftid b.gifthonor
2122 3111 2122 3331 H
Not a homework assignment. I work at a small college and have been trying to figure this out for several months
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply