Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Data required in specific format

Author  Topic 

piyushpardeshi4u
Starting Member

2 Posts

Posted - 2012-03-27 : 09:50:53
I have table say Product
having data as follows with column name as ProductCode and ProductDetails

ProductCode ProductDetails
---------------------------
Name maruti
Code M001
Qty 100
Name suzuki
Code N001
Qty 1000

Required output as:

Name Code Qty
Maruti M001 100
Suzuki N001 1000

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-03-27 : 10:01:51
how do you relate the Code M001 belongs to maruti or suzuki ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

piyushpardeshi4u
Starting Member

2 Posts

Posted - 2012-03-27 : 10:09:05
M001 for maruti and M002 for susuki
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-03-27 : 10:21:07
yes. How do you determine that ? I don't see any relation of that in your table

Basically, what i am trying to say is, there is no way to know from you table that M001 is for maruti and M002 is for susuki


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-27 : 11:59:36
quote:
Originally posted by piyushpardeshi4u

M001 for maruti and M002 for susuki


do you've another field in table which indicates which Name,Code,Qty values should be grouped together?
You cant rely upon order in which they're displayed as there's no concept of order in sql table unless you specify it explicitly by means of order by. So for that also you require a field

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -