473,473 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SQL for counting number of times a varchar repeated in a table

2 New Member
Hi All,
Could you please help me with writing a sql for counting number of times a varchar (1000) repeated in the table. I think I cannot use groupby/distinct etc.
Please give me an idea how I could do that if I want the output
such that each row is the varchar (distinct) and number times it repeated.
I was trying several things but it did not work :(
select tab1.varchar_col , tab2.CNT from tab tab1 ( select count(*) from tab group by varchar_col) as tab2 ...

Thanks,
Raghu
Dec 7 '07 #1
3 3437
docdiesel
297 Recognized Expert Contributor
Hi,

Expand|Select|Wrap|Line Numbers
  1. SELECT
  2.   varchar_col, count(varchar_col) as cnt
  3. FROM
  4.   tab1
  5. GROUP BY
  6.   varchar_col;
should work.

Regards,

Bernd
Dec 8 '07 #2
raghunath1981
2 New Member
Hi Bernd,

Thanks a lot for the reply.. i tried it but I am getting the error below.
I was wondering if we can user varchar in group by at all ?...

SQL1585N A system temporary table space with sufficient page size
does not exist.

Thanks,
Raghu
Dec 9 '07 #3
docdiesel
297 Recognized Expert Contributor
Hi,

your rows are to big for the 4K standard temp tablespace, where sorts etc. are to be done. Create a system temp. tablespace with 8K, maybe 16K size, as the error message says ("CREATE SYSTEM TEMPORARY TABLESPACE"). See also IBMs documentation at http://publib.boulder.ibm.com/infoce...n/t0005216.htm .

Regards,

Bernd
Dec 10 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Adam i Agnieszka Gasiorowski FNORD | last post by:
I need help width formulating the most effective (in terms of processing time) SQL query to count all the "new" documents in the repository, where "new" is defined as "from 00:00:01 up to...
10
by: Sunny K | last post by:
Hi guys, I have a field in my DB called EventDate as a DateTime field, therefore it holds both the date and time together like this: '2004-10-14 08:42:57.000'. I need to add together all the...
2
by: Glenn Cornish | last post by:
I have 5 fields in a table into which numbers between 1 and 45 can be entered. What I am having trouble with is being able to find out is how many times a particular number appears, regardless of...
3
by: Megan | last post by:
hi everybody- i'm having a counting problem i hope you guys and gals could give me some help with. i have a query that retrieves a bevy of information from several different tables. first let...
18
by: ChadDiesel | last post by:
I appreciate the help on this group. I know I've posted a lot here the last couple of weeks, but I was thrown into a database project at my work with very little Access experience. No other...
7
by: sathyashrayan | last post by:
Group, Following function will check weather a bit is set in the given variouble x. int bit_count(long x) { int n = 0; /* ** The loop will execute once for each bit of x set,
29
by: n00m | last post by:
http://www.spoj.pl/problems/SUMFOUR/ 3 0 0 0 0 0 0 0 0 -1 -1 1 1 Answer for this input data is 33. My solution for the problem is...
8
by: Elfae | last post by:
I have searched high and low for a sample for this, and I just can't find any. Sorry for the length! Background Information The issue revolves around setting up a system-generated increase in...
1
by: neenaprasad | last post by:
In the table the fields are id, first_name, last_name, introduced_by (which is integer value i.e., 1,2,3,4,5...). This number occurs more than once in the table. I have to count the number of times...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.