Solved

Edit this query?

Posted on 2006-11-01
2
137 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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 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

19 Experts available now in Live!

Get 1:1 Help Now