Solved

Edit this query?

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 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