|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 12:14 AM
Points: 62,
Visits: 358
|
|
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
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 3:05 AM
Points: 37,675,
Visits: 29,927
|
|
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 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Today @ 12:53 AM
Points: 150,
Visits: 1,026
|
|
| 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
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 12:14 AM
Points: 62,
Visits: 358
|
|
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..
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Saturday, May 18, 2013 6:46 PM
Points: 1,074,
Visits: 1,076
|
|
bhushan_juare (2/4/2013) 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
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
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Saturday, May 18, 2013 6:46 PM
Points: 1,074,
Visits: 1,076
|
|
bhushan_juare (2/4/2013) Hi All, I am unable to do that using Case statement.. Bhushan
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
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 3:18 AM
Points: 2,211,
Visits: 4,164
|
|
bhushan_juare (2/4/2013) 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
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
Kingston Dhasian
How to post data/code on a forum to get the best help - Jeff Moden http://www.sqlservercentral.com/articles/Best+Practices/61537/
|
|
|
|