February 4, 2013 at 5:53 am
[font="Courier New"]Hi All,
I Have table where it includes fields model_size, model_type, actual_qty, process_qty, order_type. Now I want to display all fields + model_size who has order_type = 'Some X' but I am unable to do that using Case statement..
All suggestion are welcome..
Thanks..
Bhushan[/font]
February 4, 2013 at 6:15 am
Case statement is probably what you're looking for, but not enough information to be sure.
All this is in one table? What do you want the model size column to show for rows that have other order types?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
February 4, 2013 at 6:16 am
Why case? You need a simple select and a where condition or I don't understand your question. Post example data and result then it will be easier
February 4, 2013 at 10:17 pm
To show which model_type is coming in next phase and so on for production...
Hence i have to show that field also along with actual_qty..
February 4, 2013 at 10:31 pm
bhushan_juare (2/4/2013)
[font="Courier New"]Hi All,I Have table where it includes fields model_size, model_type, actual_qty, process_qty, order_type. Now I want to display all fields + model_size who has order_type = 'Some X' but I am unable to do that using Case statement..
All suggestion are welcome..
Thanks..
Bhushan
[/font]
See that's how your statement look like
CREATE TABLE #Fields (model_size INT, model_type VARCHAR(10), actual_qty INT,process_qty, order_type Char(3) )
-- display all fields + modelsize where ordertype='X'
Select model_size, model_type, actual_qty, process_qty, order_type from #Fields
Where order_type = 'Some X'
You must give out the exact information to get the solution ..
Give the table information DDL's like create table statements; and the sample data and the resultset data that you are looking for ..
~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one :ermm:
February 4, 2013 at 10:38 pm
bhushan_juare (2/4/2013)
[font="Courier New"]Hi All,I am unable to do that using Case statement..
Bhushan
[/font]
that's how you implement case statement
CREATE TABLE #Fields
(
MODEL_SIZE INT,
MODEL_TYPE VARCHAR(10),
ACTUAL_QTY INT,
PROCESS_QTY INT,
ORDER_TYPE CHAR(3)
)
insert into #Fields values (1,'abc',10,5,'t'),
(2,'bcd',10,5,'y'),(3,'abcd',10,5,'z')
SELECT MODEL_SIZE,
MODEL_TYPE,
ACTUAL_QTY,
PROCESS_QTY,
ORDER_TYPE,
( CASE
WHEN ORDER_TYPE = 't' THEN 'new'
ELSE 'existing'
END )AS attribinfo
FROM #Fields
~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one :ermm:
February 5, 2013 at 2:31 am
bhushan_juare (2/4/2013)
[font="Courier New"]Hi All,I Have table where it includes fields model_size, model_type, actual_qty, process_qty, order_type. Now I want to display all fields + model_size who has order_type = 'Some X' but I am unable to do that using Case statement..
All suggestion are welcome..
Thanks..
Bhushan
[/font]
Your explanation is not very clear and hence gives rise to confusions
Please provide DDL of the tables involved along with some sample data and the expected results
This will help us give you a tested answer
If you don't know how to do this, read the link in my signature
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply