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 |
|
paramu
Posting Yak Master
151 Posts |
Posted - 2012-01-05 : 04:12:55
|
| Iam using sql server 2008. Employee Table==============employee_no, employee Name1001 SQL Team1022 KRISTEN1033 VISAKH1044 PARAMUSHP23 SOME NAME35MECH ANOTHER1021 SOME XSHP15 SOME Y25MECH SOME ZTIMESHEET TABLE:================select * from timesheet_tbl tm where tm.employee_no in(select e1.employee_no from employee-tbl e1 where e1.emplyee_no>='1033' and e1.employee_no<='1021');The above query gives only for employee_no 1033 and 1021But I need1033,1044,SHP23,35MECH,1021So how to achieve like this ?ThanksParamu @ PARANTHAMAN |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-01-05 : 04:17:51
|
but these emplyee_no "1044,SHP23,35MECH" does not falls between '1033' and '1021' ! run this and see how the employee_no is orderedselect * from [employee-tbl] order by employee_no KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
paramu
Posting Yak Master
151 Posts |
Posted - 2012-01-05 : 04:33:54
|
| Hi,Khtan thanks..when I check with order by it's missed some nos.But my requirement is like the above I mentioned..Is it possible?ThanksParamu @ PARANTHAMAN |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-01-05 : 04:38:56
|
when you use >= or <= it is considering the alphabetical order of the value in emplyee_no column.quote: But I need1033,1044,SHP23,35MECH,1021
WHERE emplyee_no IN ('1033', '1044', 'SHP23', '35MECH', '1021') KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
paramu
Posting Yak Master
151 Posts |
Posted - 2012-01-05 : 04:46:04
|
| Hi Khtan...Thanks for the reply. Actually I don't the values, It has to be select from the Query.Thanks Again...Paramu @ PARANTHAMAN |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-01-05 : 04:54:10
|
so how do you decide what are the records you need ? is there any other column in the table that you can based the criteria on ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
paramu
Posting Yak Master
151 Posts |
Posted - 2012-01-05 : 05:19:25
|
| As per the requirement no other column, I have to select from employee_no only.Thank You Khtan.Paramu @ PARANTHAMAN |
 |
|
|
|
|
|
|
|