Solved

Edit this query?

Posted on 2006-11-01
2
142 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Website Test Question 6 131
Splitting up a coldfusion site into 2 separate sites in IIS 3 104
Connect to MS-SQL server from Linux/PHP 8 96
Linux Hosting 16 76
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
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…

749 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