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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|