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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Convert nvarchar which is single letter to number

Author  Topic 

HWebster
Starting Member

4 Posts

Posted - 2011-11-28 : 08:28:01
Hi,

I am fairly new to SQL and I'm trying to convert nvarchar to numbers where the nvarchar is a single letter.

Can anyone help me please?

Thanks in anticipation

HWebster

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-11-28 : 08:31:09
Can you post some sample data? How will you convert letter to number?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-28 : 08:34:09
quote:
Originally posted by HWebster

Hi,

I am fairly new to SQL and I'm trying to convert nvarchar to numbers where the nvarchar is a single letter.

Can anyone help me please?

Thanks in anticipation

HWebster


single letter? you mean numeric data or character data?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

HWebster
Starting Member

4 Posts

Posted - 2011-11-28 : 10:39:27
Hi,

The table has several entries per person for various elements, each with a grade A-D. I am trying to select only the lowest grade for each person, in Report Builder and I remember someone telling me this was how to do it, but I can't remember how.

The table is as follows:

Name - float
Date - unsure
Grade - nvarchar
Element - nvarchar

If someone had one A and one D, I only want to select the D entry.

Sorry if I'm not explaining this well, as I said, it is all new to me, I do know what I'm doing but can't always articulate what I want to do in the proper way!

Many thanks.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-28 : 10:45:04
quote:
Originally posted by HWebster

Hi,

The table has several entries per person for various elements, each with a grade A-D. I am trying to select only the lowest grade for each person, in Report Builder and I remember someone telling me this was how to do it, but I can't remember how.

The table is as follows:

Name - float
Date - unsure
Grade - nvarchar
Element - nvarchar

If someone had one A and one D, I only want to select the D entry.

Sorry if I'm not explaining this well, as I said, it is all new to me, I do know what I'm doing but can't always articulate what I want to do in the proper way!

Many thanks.


ok. what has this to do with conversion you asked?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

HWebster
Starting Member

4 Posts

Posted - 2011-11-28 : 11:00:33
Hi,

My former colleague told me that to select the lowest grade I would need to convert to number then select min. Therefore, I would need to convert data in the Grade column to a number, unless there is another way to do this.

Many thanks.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-28 : 11:04:42
ok. for that what you need is a case statement like

CASE Grade
WHEN 'A' THEN 4
WHEN 'B' THEN 3
WHEN 'C' THEN 2
WHEN 'D' THEN 1
END

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

HWebster
Starting Member

4 Posts

Posted - 2011-11-28 : 12:29:00
Thanks very much!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-28 : 12:40:01
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -