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 |
|
sudha12345
Starting Member
47 Posts |
Posted - 2009-05-21 : 01:10:32
|
| i have an requirement which i has to display the data in different files based on alphabe namethe data in one of the column is as below abcbcddeffed**fed*fed(fedghiijkklmlmnmnsprsrsdNow i want to get the data as below1st fileabcbcddeffed2nd fileghiijkklmlmn3rd filemnsprsrsd4th file**fed*fed(fedcan any one help me how can we write a selec query to acheive thisSudhakar |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-05-21 : 01:16:27
|
select * from (select *, ntile(3) as recid from table where col1 like '[a-z]%') as d where recid = 1select * from (select *, ntile(3) as recid from table where col1 like '[a-z]%') as d where recid = 2select * from (select *, ntile(3) as recid from table where col1 like '[a-z]%') as d where recid = 3select * from table where col1 not like '[a-z]%' E 12°55'05.63"N 56°04'39.26" |
 |
|
|
sudha12345
Starting Member
47 Posts |
Posted - 2009-05-21 : 01:41:03
|
| Thanks for u r replywhile executing the query it is displaying an errorIncorrect syntax near 'ntile', expected 'OVER'.Can you Help me on thisSudhakar |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-05-21 : 01:44:50
|
replace all thesentile(3) as recid withntile(3) over (order by col1) as recid E 12°55'05.63"N 56°04'39.26" |
 |
|
|
sudha12345
Starting Member
47 Posts |
Posted - 2009-05-21 : 02:10:26
|
| Thanks a lot. it is fine and working.if we want to pass a parameter instead of HardCodindwe are selecting the data with the criteria like '[a-z]%can we use 1 parameter for a and 1 one parameter zwe wan to select the data with the criteria like '[parameter-parameter]% instead of a and zis it possible to do thatif possible how can we acheive thatSudhakar |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-05-21 : 02:30:12
|
where col1 like '[' + @param1 + '-' + @param2 + ']%' E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|