Solved

Edit this query?

Posted on 2006-11-01
2
138 Views
Last Modified: 2013-12-24
Experts,

In this query, I want to change the output of the "TYPE" field to only output the name in the TYPE field to the first letter of what is there.

SELECT TYPE, COUNT(*) AS count
FROM MYTABLE
WHERE NODENAME IN ('TSG','COSTAR','STE') AND CURDATE >= '2006102'
GROUP BY TYPE

Example:
If the query comes back with the following names in the TYPE field, I want them changed to their first character in the query output.

ADD_TO  =   A
IMMED    =   I
OK2GO    =   O

How do you suggest I accomplish this?
0
Comment
Question by:g118481
  • 2
2 Comments
 
LVL 20

Accepted Solution

by:
trailblazzyr55 earned 500 total points
ID: 17850602
SUBSTRING(column, start, count)

try this...

SELECT SUBSTRING(TYPE,1,1) AS TYPE, COUNT(*) AS count
FROM MYTABLE
WHERE NODENAME IN ('TSG','COSTAR','STE') AND CURDATE >= '2006102'
GROUP BY TYPE

for oracle try

SELECT SUBSTR(TYPE,1,1) AS TYPE, COUNT(*) AS count
FROM MYTABLE
WHERE NODENAME IN ('TSG','COSTAR','STE') AND CURDATE >= '2006102'
GROUP BY TYPE
0
 
LVL 20

Expert Comment

by:trailblazzyr55
ID: 17850612
this may work too...

SELECT SUBSTRING(TYPE,1,1), COUNT(*) AS count
FROM MYTABLE
WHERE NODENAME IN ('TSG','COSTAR','STE') AND CURDATE >= '2006102'
GROUP BY TYPE
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now