A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How to insert a column with certain values



 
 
Thread Tools Display Modes
  #1  
Old October 27th, 2008, 02:24 PM posted to microsoft.public.access.queries
Amin
external usenet poster
 
Posts: 181
Default How to insert a column with certain values

So this is my query:

SELECT COUNT(REGBASE) AS Occurences
FROM WFLOW
WHERE REGBASE 100000 AND STARTQUEUE IN("4ADIV","4BDIV","4CDIV","4DDIV",)
UNION
SELECT COUNT(REGBASE) AS Occurences
FROM WFLOW
WHERE REGBASE BETWEEN 100000 AND 1 AND STARTQUEUE
IN("4ADIV","4BDIV","4CDIV","4DDIV",)
UNION
SELECT COUNT(REGBASE) AS Occurences
FROM WFLOW
WHERE REGBASE = 0 AND STARTQUEUE IN("4ADIV","4BDIV","4CDIV","4DDIV",);

So this produces a table that has one Field--called Occurences) and three
records with different numbers. What I would like to do is to insert another
field to the left with three records with values "A", "B" and "C". Is this
possible without creating another table?

Thanks!
Amin
  #2  
Old October 27th, 2008, 03:00 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default How to insert a column with certain values

Try this --
SELECT "A" AS Occurences, COUNT(REGBASE) AS Occurences
FROM WFLOW
WHERE REGBASE 100000 AND STARTQUEUE IN("4ADIV","4BDIV","4CDIV","4DDIV",)
UNION
SELECT "B" AS Occurences, COUNT(REGBASE) AS Occurences
FROM WFLOW
WHERE REGBASE BETWEEN 100000 AND 1 AND STARTQUEUE
IN("4ADIV","4BDIV","4CDIV","4DDIV",)
UNION
SELECT "C" AS Occurences, COUNT(REGBASE) AS Occurences
FROM WFLOW
WHERE REGBASE = 0 AND STARTQUEUE IN("4ADIV","4BDIV","4CDIV","4DDIV",);

--
KARL DEWEY
Build a little - Test a little


"Amin" wrote:

So this is my query:

SELECT COUNT(REGBASE) AS Occurences
FROM WFLOW
WHERE REGBASE 100000 AND STARTQUEUE IN("4ADIV","4BDIV","4CDIV","4DDIV",)
UNION
SELECT COUNT(REGBASE) AS Occurences
FROM WFLOW
WHERE REGBASE BETWEEN 100000 AND 1 AND STARTQUEUE
IN("4ADIV","4BDIV","4CDIV","4DDIV",)
UNION
SELECT COUNT(REGBASE) AS Occurences
FROM WFLOW
WHERE REGBASE = 0 AND STARTQUEUE IN("4ADIV","4BDIV","4CDIV","4DDIV",);

So this produces a table that has one Field--called Occurences) and three
records with different numbers. What I would like to do is to insert another
field to the left with three records with values "A", "B" and "C". Is this
possible without creating another table?

Thanks!
Amin

  #3  
Old October 27th, 2008, 03:13 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default How to insert a column with certain values

That might have a small problems since you've aliased both fields to the same
name. You might change the first Occurences to CategoryType in each of the
queries.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County

KARL DEWEY wrote:
Try this --
SELECT "A" AS Occurences, COUNT(REGBASE) AS Occurences
FROM WFLOW
WHERE REGBASE 100000 AND STARTQUEUE IN("4ADIV","4BDIV","4CDIV","4DDIV",)
UNION
SELECT "B" AS Occurences, COUNT(REGBASE) AS Occurences
FROM WFLOW
WHERE REGBASE BETWEEN 100000 AND 1 AND STARTQUEUE
IN("4ADIV","4BDIV","4CDIV","4DDIV",)
UNION
SELECT "C" AS Occurences, COUNT(REGBASE) AS Occurences
FROM WFLOW
WHERE REGBASE = 0 AND STARTQUEUE IN("4ADIV","4BDIV","4CDIV","4DDIV",);

  #4  
Old October 27th, 2008, 04:04 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default How to insert a column with certain values

You are correct. I first used field named Table but then only glanced at the
post and saw 'Field--called Occurences' without reading the whole sentence.
--
KARL DEWEY
Build a little - Test a little


"John Spencer" wrote:

That might have a small problems since you've aliased both fields to the same
name. You might change the first Occurences to CategoryType in each of the
queries.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County

KARL DEWEY wrote:
Try this --
SELECT "A" AS Occurences, COUNT(REGBASE) AS Occurences
FROM WFLOW
WHERE REGBASE 100000 AND STARTQUEUE IN("4ADIV","4BDIV","4CDIV","4DDIV",)
UNION
SELECT "B" AS Occurences, COUNT(REGBASE) AS Occurences
FROM WFLOW
WHERE REGBASE BETWEEN 100000 AND 1 AND STARTQUEUE
IN("4ADIV","4BDIV","4CDIV","4DDIV",)
UNION
SELECT "C" AS Occurences, COUNT(REGBASE) AS Occurences
FROM WFLOW
WHERE REGBASE = 0 AND STARTQUEUE IN("4ADIV","4BDIV","4CDIV","4DDIV",);


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:24 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.