Bananahead
60 pts. | May 6 2009 7:13PM GMT
In the column that asks for name, i want name only, age i want age only. Here i get name and whefe there is information filled into the other fields i get NULL. i want to get rid of that all together. yoiu shouldn’t know there was something in the database there.
Kccrosser
1850 pts. | May 7 2009 4:36PM GMT
I am not sure I understand your objectives, but is it as simple as replacing the “NULL” with an empty string? Like:
CASE ProfileAnswers.pq_id WHEN 70 THEN ProfileAnswers.pa_value ELSE ” END AS ‘Previously Married’,
CASE ProfileAnswers.pq_id WHEN 35 THEN ProfileAnswers.pa_value ELSE ” END AS Type,
Or use a string with a blank, to avoid the empty string being interpreted as null:
CASE ProfileAnswers.pq_id WHEN 70 THEN ProfileAnswers.pa_value ELSE ‘ ‘ END AS ‘Previously Married’,
CASE ProfileAnswers.pq_id WHEN 35 THEN ProfileAnswers.pa_value ELSE ‘ ‘ END AS Type,
Bananahead
60 pts. | May 7 2009 6:44PM GMT
that wont help. the database is not empty. its showing null for all the answers that i don’t want to see in this colum. for example, lets say i want to show the age for each person in my database. it will show the name, the age and blank spaces for each of the other questions that i don’t want to show.
Bananahead
60 pts. | May 7 2009 9:07PM GMT
I tried IS NOT NULL but that doesn’t work because the database is not null. I told it to put in Null or an empty string instead of what is in that field in the database. I need that instead of showing these things, the field should not show up at all. Since all the answers are in the same column, i am having a hard time splitting this one column into a couple of different columns.
Darryn
370 pts. | May 8 2009 3:29PM GMT
This is not ideal, but it should work:
select username,
max(HebrewName) HebrewName,
max(Learning_Working) Learning_Working,
max(Previously_Married) Previously_Married,
max(Type) Type
max(Approved) Approved
from
(
SELECT DISTINCT
TOP (100) PERCENT dbo.ProfileAnswers.u_username AS Username, CASE ProfileAnswers.pq_id WHEN 101 THEN ProfileAnswers.pa_value ELSE NULL END AS HebrewName,
CASE ProfileAnswers.pq_id WHEN 42 THEN ProfileAnswers.pa_value ELSE NULL END AS ‘Learing_Working’,
CASE ProfileAnswers.pq_id WHEN 70 THEN ProfileAnswers.pa_value ELSE NULL END AS ‘Previously_Married’,
CASE ProfileAnswers.pq_id WHEN 35 THEN ProfileAnswers.pa_value ELSE NULL END AS Type, dbo.ProfileAnswers.pa_approved AS Approved,
DATEDIFF(Year, <a href="http://dbo.Us" title="http://dbo. " target="_blank">dbo.Us</a>ers.u_birthdate, GETDATE()) AS Age
FROM dbo.ProfileAnswers INNER JOIN
<a href="http://dbo.Us" title="http://dbo.
" target="_blank">dbo.Us</a>ers ON dbo.ProfileAnswers.u_username = <a href="http://dbo.Us" title="http://dbo. " target="_blank">dbo.Us</a>ers.u_username
WHERE <a href="http://dbo.Us" title="http://dbo.(" target="_blank">dbo.Us</a>ers.u_gender = 2) )
group by username






