Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Edit this query?

Posted on 2006-11-01
2
Medium Priority
?
149 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 2000 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 Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

916 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