Sorting Of A String Column
Mar 7, 2008
I have the column of type string in the database
Following is the data in that column
1
2
11
12
21
abc
If i sort the table with the help of this column then the output come in the following manner
1
11
12
2
21
abc
can i improve the order actually i want the output like 1 2 11 12 21 abc
View 2 Replies
ADVERTISEMENT
Jul 20, 2005
hi!!!would appreciate if somebody could let me know the query/algoritham tosort the following values in the column either in asc or descthe values in the column originally11-1/21-1/41/2101214161822-1/22033/44568the sorted result should be as follows1/23/411-1/41-1/222-1/234568101214161820TIA, have a great dayregardsbala
View 4 Replies
View Related
Feb 6, 2007
I've got a report built and I'm trying to figure out how sorting and grouping works. I can group the report by Patient, Albumin and it groups as I would expect.
Patient Date Albumin
Adams, John 01/28/2007 4.1
Adams, John 12/30/2007 3.9
Adams, John 01/15/2007 3.2
Barker, Mark 01/18/2007 4.3
Barker, Mark 01/22/2007 4.1
Barker, Mark 01/05/2007 3.9
However, when I try to group by Albumin, Patient, it just sorts by Albumin.
Patient Date Albumin
Barker, Mark 01/18/2007 4.3
Adams, John 01/28/2007 4.1
Barker, Mark 01/22/2007 4.1
Adams, John 12/30/2007 3.9
Barker, Mark 01/05/2007 3.9
Adams, John 01/15/2007 3.2
What I'm looking for is this:
Patient Date Albumin
Barker, Mark 01/18/2007 4.3
Barker, Mark 01/22/2007 4.1
Barker, Mark 01/05/2007 3.9
Adams, John 01/28/2007 4.1
Adams, John 12/30/2007 3.9
Adams, John 01/15/2007 3.2
Is this something that can be done with grouping and sorting?
Thanks,
Chad
View 1 Replies
View Related
May 14, 2008
Hi all,
i have this column name "Effective Date". the data inside it is like this:
01-Aug-2006
01-Jan-2007
01-Jun-2006
01-Mar-2004
01-Nov-2003
01-Oct-2005
02-Oct-2007
05-May-2006
08-Oct-2003
1-Agustus-2005
10-Feb-2002
10-Jan-2005
10-Mar-2003
11-Feb-2008
12-Dec-2006
12-May-2008
14-Nov-2006
15-Jun-2004
19-Jun-2007
22-Mar-2007
23-Apr-2007
23-Jan-2008
26-Feb-2008
27-Jan-2005
27-Mar-2007
27-Sep-2007
How to sort the column? i've using Order by [Effective Date], but it doesnt work.
please help.
thanks,
Addin
View 8 Replies
View Related
Jan 27, 2014
I need to sort on a column that has a mix of alpha/numeric...
oActual Sort: A1, A100, A14, A2, A222, A25 …
oFavored Sort: A1, A14, A100, A2, A25, A222 …
View 4 Replies
View Related
Jul 20, 2005
We've just installed SQL Server 2000 on one of our servers and havenoticed a strange behavior. When clicking the column headings in thejob display in Enterprise Manager, the list is sorted (first clickascending, then descending) on the column clicked except for "Next RunDate." When we click on "Next Run Date," the list is reordered, butrandomly. Each time we click it we get a different order but neverascending or descending. This is true whether we're at the server oron a remote machine. We never saw this behavior with SQL Server 7.0.Any ideas? Thanks!
View 4 Replies
View Related
Nov 26, 2007
Hi, I have a table whose Identifying column is not an integer but rather a manually entered id. (i.e. 106F, 106-09, G11 etc.) When sorted ascending, a G11 will come before a G2 in the list, 106-11 before 106-2, etc.I would like to insert a new column in the database or use some kind of function when sorting the database to ensure that the list in returned in the proper order. Any ideas?Much appreciated...
View 16 Replies
View Related
Oct 30, 2007
I have a matrix with the rows consisting of customers and the columns consisting of different revenue streams. The revenue streams are totalled using the matrix subtotal feature. I would like to sort, either interactively or statically (if that is the only option) by the subtotal column. I've read through everything I can find online and even the solutions that appear to be appropriate do not work. Can anyone give me a suggestion?
Thanks,
Zack Gallinger
View 5 Replies
View Related
Jan 21, 2008
can anyone please help on a sql statement that would sort out three kinds of data. let's say i have a column that contains a status flag. there are only 2 possible values, add and delete. now, i want to sort out three kinds of data: add_only, delete_only, and update. Update is the data that contains duplicate records in the table. Which means, there are two rows having same "student_number" but two different status flags. This happens when there's an update or change in data, such as new address or new phone number. The old row/data is sent with status flag of delete, while the updated data is sent with status flag of add. Example below. An output table with a new column of tag is created.
reports table
STUDENT_NO
NAME
ADDRESS
PHONE
STATUS FLAG
1
McKenzie
Ohio
9111111
add
2
Hario
New Jersey
1234567
add
3
Oda
Japan
9876543
delete
4
Davis
Chicago
1112222
add
5
Rodriguez
Detroit
4445555
add
1
McKenzie
Ohio
7778888
delete
4
Davis
Detroit
1112222
delete
create, remove, update table
STUDENT_NO
NAME
ADDRESS
PHONE
STATUS FLAG
TAG
2
Hario
New Jersey
1234567
add
create
5
Rodriguez
Detroit
4445555
add
create
3
Oda
Japan
9876543
delete
remove
1
McKenzie
Ohio
9111111
add
update
4
Davis
Chicago
1112222
add
update
Anyone knows what SQL statements to use to have this output? Thanks.
View 6 Replies
View Related
Nov 27, 2007
Hi
I have Constructed a table
Table Name : MasterEntry
Column Name:
MasterEntryNumber
ServiceName
ServiceDepartment
EmployeeName
MasterEntryNumber is GenerationNumber where ever any entry is happen in table
if put a queries [select * From masterentry Order by MasterentryNumber] is give output in ascending order
e.g MasterEntryNumber has
1
2
3 it give correct ordering
but if i exceed more 10 if i put same queries
Output of queries is
1
10
11
2
3 this is the out of the queries if it exceed more 10 rows
i want queries should be look like this
1
2
3
...... 10
did any have experience on this issue please let me know where i can fix
kinds regards
View 8 Replies
View Related
May 21, 2014
I am trying to sort this simplied table:
ID - Time
1 2000-2001
2 2002-
3 2001-2003
4 1999
5 2005-2006
I want this as a result:
1999
2000-2001
2001-2003
2005-2006
2002-
Because the "-" means "continues", it the thing is still activated, so if it makes it easier, i could put the today's year afterwards during the query, if it ends with a - ...
Now, simply doing a
SELECT * FROM [table] ORDER BY TIME;
Sorts it "perfectly", apart from the "2002-" is just placed before 2005 and after 2001.
So, of course, it fails on all entries with a leading "-" ...
Right when I clicked "submit", of course, I can simply replace all entries with a time ending with "-", with the todays Year, so at least they will get at the end of the query...
Well, have to do a union, first sorting all without the "-", then sorting all with the "-", and that should be it...
View 5 Replies
View Related
Apr 9, 2008
Hi All,
I want to sort the column data which is of positive and negative number like the following.
-5823
-1
200
100
i want to sort like
-1
100
200
-5823
How can i do that can any one help me..
Thanks in advance.
-john
View 10 Replies
View Related
Aug 24, 2007
Hi All,
Is there any command which will sort data in text file based on 3rd column (based on any column)?
Thanks
Sanjeev
View 1 Replies
View Related
Feb 25, 2008
Hello,
I have data coming in from two sources, one being SQL and the other being Oracle. The end result needs to be a CSV file with the columns in a specific order. I have a Data Flow task setup that takes both sources and does a Merge Join on them. I can add a Sort Transformation and manually set the sorting of all 156 columns that end up going to a CSV file destination. However, I have a table setup that holds the names of the 156 columns and the order that the CSV file expects them to be in. I would much rather do this step dynamically as the column names and order may change in the future. Anyone who has used the Sort Transformation for a large number of columns knows how tedious it can be and how adding a column in the middle will cause you to change the sort # for each of the columns that come after it.
So I added a Script Component between the Merge Join and the Flat File Destination hoping that I could alter the order of the columns there. However I added the following code and found that the SortKeyPosition is ReadOnly.
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
Dim column As IDTSInputColumn90
For Each column In Me.ComponentMetaData.InputCollection(0).InputColumnCollection
column.SortKeyPosition = 1
Next
End Sub
I was hoping to add some code to get the sort index from my table for each of the columns and set it to the SortKeyPosition. Has anyone out there done this before or seen an example that might point me in the right direction? I've searched for 2 days without coming up with much.
Thanks!
View 5 Replies
View Related
Aug 14, 2007
Hi,
I have a matrix report...the column results
are as follows
Con Std , Con Access, SF Std, SF Acc, Broadband, Pay TV
how would i make the columns appear in the above order when displaying as it is default alphetically sorted...I have tried putting numbers at the front which work till I get to the number 10 which alphetically sorted is next to 1 not 9?
is there a better way off sorting matrix column which have no specific criteria to sort from?
thanks
View 6 Replies
View Related
Oct 29, 2015
I am creating a Matrix report using SSRS/Visual Studio 2008 as below:
Jan
Feb
March
April
May
June
July
Aug
Sept
Oct
A & B are customers. The values represent sales for each month.I have got most parts in place except the Month are displayed in random order (1,10,2,3,4,5,6 and so on).I have tried the option to create a calculated column with month numbers and change group properties but that did not work.how to get it to sort display as 1,2,3,4,5,6,7,8,9,10.
View 6 Replies
View Related
Jan 27, 2015
I am having problem with the unpivot function of sql 2012, i unpivot my column then i get the result that i wanted but the error that i was encountering was the unpivot is automatically sort the column in alphabetically order which is not I desire,
Here is my code
@syear nvarchar(50)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
[Code] ....
View 1 Replies
View Related
Aug 7, 2015
I have a tablix that looks like this...
30 Jul
31 Jul
01 Aug
02 Aug
03 Aug
04 Aug
05 Aug
Region1
0.00
0.00
0.00
0.00
100.00
100.00
0.00
[code]....
I would like to sort the last column which is a dynamic date (always the most recent from the last 7 days) from 0 to 100.
View 11 Replies
View Related
Feb 11, 2007
I have a report where I am giving the users a parameter so that they can select which field they would like to sort on.The report is also grouping by that field. I have a gruping section, where i have added code to group on the field I want based on this parameter, however I also would like to changing the sorting order but I checked around and I did not find any info.
So here is my example. I am showing sales order info.The user can sort and group by SalesPerson or Customer. Right now, I have code on my dataset to sort by SalesPerson Code and Order No.So far the grouping workds, however the sorting does not.
Any suggestions would help.
Thanks
View 1 Replies
View Related
Jul 10, 2015
SSRS 2012 - VS2010...The report compares two years with a sort order on a value that has been engineered based on text switched to int. When sorting A-Z this is the result in the horizontal axis is: 5th, K, 1st, 2nd, 3rd, 4th, 5th..When sorting Z-A the result in the horizontal axis is:5th, 4th, 3rd, 2nd, 1st, PreK..Z-A is correct but A-Z sorting shows 5th as the start and end. The magnitude of the PreK location is correct but the label is wrong on the A-Z sort order. The sorting is implemented using the Category Group sorting option.
View 6 Replies
View Related
Sep 24, 2015
I am trying to sort my sql resultset by an alphanumeric column of a table which is of NVARCHAR datatype. The sample data is given below:
CREATE TABLE #Activities(activityName NVARCHAR(100))
INSERT INTO #Activities VALUES('Field phase S14-04932-01')
INSERT INTO #Activities VALUES('Phase reporting')
INSERT INTO #Activities VALUES('Phase running')
INSERT INTO #Activities VALUES('RD1')
[Code] ....
The output of the query is like this:
A1
A2
A3
A4
E1 0DAA1
E10
E2 0DAA2
[Code] .....
The output what I require is this:
A1
A2
A3
A4
E1 0DAA1
E2 0DAA2
[Code] ....
View 9 Replies
View Related
Aug 2, 2007
I have a matrix report with 2 column SaleAmount and ProfitAmounts by Month like
Sale Profit
Dealer 5/1/2007 6/1/2007 7/1/2007 5/1/2007 6/1/2007 7/1/2007
A 100 200 300 20 25 15
B 200 250 50 30 45 19
how can i do following 3 things
1)Add Total column for Sale and Average column for Profit
2)Sort report by lastMonth of Sale (here 7/1/2007) High to low
3)if last month of sale(here 7/1/2007) is less than second last month here (6/1/2007) whole row should be red
thanks
View 1 Replies
View Related
Mar 5, 2007
Hi,
I have dates in "mmddyy" format coming from the sources and they are older dates of mid 80s like 082580 for instance.
When I cast it this way (DT_DBTIMESTAMP) Source_Date , It says ok but throws a runtime error.
When I hardcode a date in same format, (DT_DBTIMESTAMP) "082580" , It becomes red (an indication of syntax error) . Please note that we use double quotes in expressions in Derived Column Transformation; So an anticipation that using double quotes over single ones would be the syntax problem would be wrong.
Any help in this will sincerely be appreciated.
Thanks
View 7 Replies
View Related
Nov 8, 2006
I having a column formatted as char(12) being used for indexing. I am not getting the correct max value back from the statement:
"SELECT MAX(ID) FROM STAGING_TABLE"
i.e.
ID column contains 45,999,1726..The returned val for the query above is 999. Any ideas? TIA
View 1 Replies
View Related
Dec 14, 2007
Hi All,
I have a table which contains values like this :
Column 1 Column 2
A 1
A 2
A 3
B 1
B 2
In need the output in this format:
Col1 Col 2
A 1,2,3
B 1,2
Can anyone help me with this ????
View 3 Replies
View Related
Jun 18, 2007
hey everyone, everyone here has been extremely helpful, I'm extremely appreciative. i have another question if anyone has the time.I want to pull the value of one column/row into a string, i know this value to be one int or 1 word under 10 characters. I'd like to be able to use this variable as a conditional, so my if/else statements have information to work off of. I have been using the following format in by code-behind pages to do my SQL insert/update/delete - however I cannot figure out how to SELECT and get those results into a string. I'm new obviously, so dumbed-down explanation would be greatly appreciated!This is what I've used so far for working with my DB:using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls; protected void Button1_Click(object sender, EventArgs e) { SqlDataSource profilesinsert = new SqlDataSource(); profilesinsert.ConnectionString = ConfigurationManager.ConnectionStrings["ProfilesConnectionString1"].ToString(); profilesinsert.InsertCommandType = SqlDataSourceCommandType.Text; profilesinsert.InsertCommand = "INSERT INTO ProfileComments (Approved) VALUES (@Approved)"; profilesinsert.InsertParameters.Add("Approved", "yes"); profilesinsert.Insert(); } The SELECT into a string I'd like to do on page_load, so that I can test that variable upon button click, and have a different value in "Approved" depending on the 1 int or small word result from my SELECT.THANK YOU very much to anyone who offers help! love you guys :)
View 19 Replies
View Related
Nov 13, 2003
Hello I currently am using the nvarchar type which has a maximum size of 4000 char's. Is there any other type that I can use which can store a greater amount of char's ?
Many thanks
Grant
View 2 Replies
View Related
Mar 26, 2004
I have a column of 5 comma-separated-value strings:
stringA, stringB, stringC, stringD, stringE
The strings are GUID's with the hyphen stripped and made all uppercase so they are completely random. I need to be able to remove any one of the strings including the comma, in a stored procedure and I am not sure how to accomplish this.
SELECT tickets
FROM users
WHERE CONTAINS (tickets, @ticket)
IF @@rowcount > 0
REMOVE STUFF HERE
SET @valid = 1
ELSE
SET @valid = 0
So if stringB gets passed in as @ticket then the new value in the column would be :
stringA, stringC, stringD, stringE
Any help is greatly appreciated.
Thank you
dave
View 9 Replies
View Related
Aug 13, 2003
Hi All,
I am trying to write a select statement which will concatenate all values of a string column and provide me with a result set containing just one row of data containing a concatenation of all values.
For eg:
column1
abc
def
hij
klm
nop
is it possible to write a select statement which would return
result
abcdefghijklmnop
as a result?
TIA
Ketan
View 6 Replies
View Related
Oct 1, 2013
I have access to a database's web front end and a limited amount of access to the server.
I am trying to find out what column a certain string is in.
I can see some text on the front end via the web that a user enters and then submits. This information must go to the back end of the database but I dont know where it goes...
I am able to provide a unique Sequence number that it would be linked with and obviously I have the string that im looking for its column name but other then that I dont know what I can do.
I don't have write access to the database so I am unable to make procedures. I am also not really aware how the front end works or if I would be able to find the script that deals with the text after the user hits "save"...
View 14 Replies
View Related
Apr 3, 2008
Good Morning,
I'm trying to write a scrip to compate two columns in two different tables to each other (billing_payee to Debtor_name)
The problem i have is that the info in the billing_payee column is CLIENT RE DEBTOR INITAL SURN and the infor in Debtor_name column is [i]DEBTOR TITLE NAME SURN[i]
What i need to be able to do is select all from Billing_Payee table where the Billing payee [i]DEBTOR INIAL SURN[i] is not the same as the info in Debtor_name.
I somehow need to split out the inial - first letter of debtor name and surname.
If i can't do it this way i need some other way of comaparing the two.
I am fairly new to t-SQL however have a pretty good grasp of it.
Please let me know if there is anything else i can provide to make this any easier any help is much appreciated!!
View 5 Replies
View Related
Mar 2, 2015
How to separate column FullName to three column LastName, FirstName, and MI? Sample of FullName - Smith, John P.
View 4 Replies
View Related
Jan 21, 2008
I want to concaternate all rows that has the same ID and update another table.
Table1:
ID: COL1
1 txt1
1 txt2
1 txt3
2 txt7
3 txt5
3 txt6
OUTPUT:
ID: COL1:
1 txt1, txt2, txt3
2 txt7
3 txt5, txt6
How do I manage this, have tried self join but with no luck.
View 2 Replies
View Related