| Author |
Topic |
|
rookie_sql
Constraint Violating Yak Guru
443 Posts |
Posted - 2008-08-15 : 11:30:10
|
| Hey i have 2 tables one is product and the other is barcodes.the join between the 2 tables is the p-code.Am trying to return back the barcodes from the barcode table base on the pack size in the product table if the pack size = 1 then its then return the inner_barcode else its the outter_barcode these results are all displayed in the same columnI did a case on it in a view but its not returning back all my data here is my code.select p-code,CASE when pack = 1 then inner else outter as barcodefrom barcodeinner join product on [product.p-code] = [barcode.p-code] |
|
|
Vinnie881
Master Smack Fu Yak Hacker
1231 Posts |
Posted - 2008-08-15 : 11:42:23
|
your case statement is missing a endselect p-code,CASE when pack = 1 then inner else outter END as barcodefrom barcodeinner join product on [product.p-code] = [barcode.p-code] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-15 : 11:43:03
|
first of all your case is missing an end clauseselect p-code,CASE when pack = 1 then inner else outter end as barcodefrom barcodeinner join product on [product.p-code] = [barcode.p-code] when you say you're not getting all data expected are you sure product table has atleast a record for each p-code in barcode? Can you explain discrepancy by means of some sample data? |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-08-15 : 11:43:56
|
[code]select p.[p-code], case when pack = 1 then inner_barcode else outer_barcode end as barcodefrom product p inner join barcode b on p.[p-code] = b.[p-code][/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-08-15 : 11:44:33
|
  KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
rookie_sql
Constraint Violating Yak Guru
443 Posts |
Posted - 2008-08-15 : 11:54:13
|
| Sorry i was missing the END and it turns out there was a space in my [p-code] on the barcode table don't worry its test data thanks for your help guys. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-15 : 11:56:20
|
quote: Originally posted by rookie_sql Sorry i was missing the END and it turns out there was a space in my [p-code] on the barcode table don't worry its test data thanks for your help guys.
No probs..In the end Vinnie turned out the winner in marathon beating us both |
 |
|
|
Vinnie881
Master Smack Fu Yak Hacker
1231 Posts |
Posted - 2008-08-15 : 12:19:36
|
| Chalk that one down on the calenders.. It doesn't happen often :) |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2008-08-15 : 12:22:14
|
quote: Originally posted by khtan
  KH[spoiler]Time is always against us[/spoiler]
Just thinking Khtan,What is the maximum number of sniped yaks you've posted at once?-------------Charlie |
 |
|
|
|