April 12, 2012 at 8:20 am
hi
i am having trouble in select stm
select "heading1" = case when (condition) then
item1
else item1
end
from tablename
in the else part i am getting so many item1 like
item1
item1
item1........
i just want one item1 ,not the duplicate
April 12, 2012 at 8:33 am
It's hard to say without a proper example with DDL and sample data. You've got item1 in both sides of your CASE .. ELSE expression.
But perhaps a "SELECT TOP 1" is what you're looking for.
April 12, 2012 at 8:38 am
ill come in and say it could be a select distinct... but even so DDL (Create table statements) and sample data (Insert statements) will be incredibly helpful in this case
help us help you and see the link in my signature if you need help on how to post the ddl and sample data.
For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]
Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
Jeff Moden's Cross tab and Pivots Part 1[/url]
Jeff Moden's Cross tab and Pivots Part 2[/url]
April 12, 2012 at 9:02 am
i m getting values like this
null
null
item1
null
null
how to tremove null
April 12, 2012 at 9:04 am
use WHERE clause:
WHERE [value] IS NOT NULL
April 12, 2012 at 9:13 am
If you really want help, help us. Please post the CREATE TABLE statement(s) for the table(s) involved, sample data as a series of INSERT INTO statements for the table(s), and your expected results based on the sample data you provide.
April 12, 2012 at 9:14 am
i did.stil its not working
April 12, 2012 at 9:23 am
hbtkp (4/12/2012)
i did.stil its not working
with out seeing your table structure the sample data in that table and the query you are trying to run we can go no further. if you would still like help, help us help you and see the link in my signature for how to post DDL and Sample data.
For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]
Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
Jeff Moden's Cross tab and Pivots Part 1[/url]
Jeff Moden's Cross tab and Pivots Part 2[/url]
April 12, 2012 at 9:25 am
You already have another thread on this same topic. http://www.sqlservercentral.com/Forums/Topic1281058-392-1.aspx You didn't get the answer you wanted there, because you didn't provide the requested information. Starting a new thread isn't going to change that.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
April 12, 2012 at 11:05 am
i dont have this thread before.
yes i need to get same values in else also
April 12, 2012 at 11:08 am
hbtkp (4/12/2012)
i dont have this thread before.yes i need to get same values in else also
drew.allen is saying that you have asked a similar question in the above posted thread which you opened before this one. and when you did not get your answer you opened another asking the same question a different way and getting the same result. "Post sample DDL and Data" please pick a thread and post the table deffinition scripts and the sample inserts and you will get your answer so much quicker. please read the link in my signature for how to post the DDL and sample data.
For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]
Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
Jeff Moden's Cross tab and Pivots Part 1[/url]
Jeff Moden's Cross tab and Pivots Part 2[/url]
April 12, 2012 at 11:09 am
Here is the complete solution based on the information you have provided so far.
select ? from ?
Why are you so stubborn about posting ddl and sample data? If you would just post this you would get help. The help would be quick and the solution even quicker.
You have not provided enough information for anybody to have a chance at helping you.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
April 12, 2012 at 11:31 am
Sean Lange (4/12/2012)
Why are you so stubborn about posting ddl and sample data?
I've come to the conclusion that he's not really interested in answers. He's only interested in monopolizing the conversation.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
April 12, 2012 at 11:38 am
drew.allen (4/12/2012)
Sean Lange (4/12/2012)
Why are you so stubborn about posting ddl and sample data?I've come to the conclusion that he's not really interested in answers. He's only interested in monopolizing the conversation.
Drew
WWSD -- Probably tell us to leave the thread.
April 12, 2012 at 11:40 am
Lynn Pettis (4/12/2012)
drew.allen (4/12/2012)
Sean Lange (4/12/2012)
Why are you so stubborn about posting ddl and sample data?I've come to the conclusion that he's not really interested in answers. He's only interested in monopolizing the conversation.
Drew
WWSD -- Probably tell us to leave the thread.
nah see how long we can go with out getting the DDL and sample data and see if we can break 100 posts.
For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]
Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
Jeff Moden's Cross tab and Pivots Part 1[/url]
Jeff Moden's Cross tab and Pivots Part 2[/url]
Viewing 15 posts - 1 through 15 (of 17 total)
You must be logged in to reply to this topic. Login to reply