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.
| Author |
Topic |
|
cwtriguns2002
Constraint Violating Yak Guru
272 Posts |
Posted - 2007-03-09 : 21:30:29
|
| Hi all. Hiw can i create a field in a query? /*table - HrSetTaxTabletaxpaytype taxcode salrate1 salrate2 basetax peroverA A1 1000 200 100 5B A2 2000 300 90 5B A3 3000 400 80 5A A4 4000 500 70 5C A5 5000 600 60 5B A6 6000 700 50 5C A7 7000 800 40 5*/How could I add another field(varchar type) named TTP. If taxpaytype is equal to A, TTP = DailyIf taxpaytype is equal to B, TTP = WeeklyIf taxpaytype is equal to C, TTP = Monthlyso my expected result./*taxpaytype taxcode salrate1 salrate2 basetax perover TTPA A1 1000 200 100 5 DailyB A2 2000 300 90 5 WeeklyB A3 3000 400 80 5 WeeklyA A4 4000 500 70 5 DailyC A5 5000 600 60 5 MonthlyB A6 6000 700 50 5 WeeklyC A7 7000 800 40 5 Monthly*/Thanks.-Ron- |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-09 : 21:40:29
|
[code]select taxpaytype, taxcode, salrate1, salrate2, basetax, perover, TTP = case taxpaytype when 'A' then 'Daily' when 'B' then 'Weekly' when 'C' then 'Monthly' else '' endfrom HrSetTaxTable[/code] KH |
 |
|
|
|
|
|