| Author |
Topic |
|
cipriani1984
Constraint Violating Yak Guru
304 Posts |
Posted - 2009-09-23 : 05:55:45
|
| Hi,Ive got the following tableField1, Field2, Field3Argos, London, 4Argos, Manch, 3HMV, Mach, 6How can I write a query to add another row HMV, London, valuecase when(Field1 = 'HMV' AND Field2 <> 'London') THEN Value ELSE 0That doesnt work as I thought it wouldThanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-09-23 : 06:49:56
|
add another row or column ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
cipriani1984
Constraint Violating Yak Guru
304 Posts |
Posted - 2009-09-23 : 06:59:03
|
The table looks like thisField1, Field2, Field3Argos, London, 4Argos, Manch, 3HMV, Mach, 6I want it to look like thisField1, Field2, Field3Argos, London, 4Argos, Manch, 3'HMV, London, [int]' <---- New rowHMV, Mach, 6What could I do, what kind of query/logic?quote: Originally posted by khtan add another row or column ? KH[spoiler]Time is always against us[/spoiler]
|
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-09-23 : 07:14:34
|
like this ?select Field1, Field2, Field3 from yourtableunionselect Field1 = 'HMV', Field2 = 'London', Field3 = 0 KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
Kabila
Starting Member
33 Posts |
Posted - 2009-09-23 : 07:36:54
|
| create table t(field1 varchar(10),field2 varchar(10),field3 int)SELECT DISTINCT a.field1,t1.field2 FROM ( SELECT DISTINCT field2 FROM T ) AS T1CROSS JOIN T as ALEFT OUTER JOIN T as b ON A.field2 = b.field2and A.field3 =b.field3exceptselect field1,field2 from t |
 |
|
|
|
|
|