I want my output in two columns like this:
C_INCIDENT_TYPE \ TOTAL COUNT
How do I combine my two queries to get result.
First Query
SELECT C_INCIDENT_TYPE, COUNT (*)
FROM TABLE_AUDIT
WHERE SUBSTR(I_USER,7,2) IN ('AD','WF','F5')
AND SUBSTR(I_IMAGE_COPY,12,8) > '00000000'
AND SUBSTR(I_IMAGE_COPY,12,8) < '99999999'
AND D_H_STAMP BETWEEN '2007-06-01-00.37.30.124670' AND
'2007-06-30-00.37.30.124670'
GROUP BY C_INCIDENT_TYPE
ORDER BY 2
WITH UR
Second Query
SELECT C_INCIDENT_TYPE, COUNT (*)
FROM TABLE_AUDIT
WHERE SUBSTR(I_USER,7,2) NOT IN 'AD','WF','F5')
AND SUBSTR(I_IMAGE_COPY,12,8) > '00000000'
AND SUBSTR(I_IMAGE_COPY,12,8) < '99999999'
AND D_H_STAMP BETWEEN '2007-06-01-00.37.30.124670' AND
'2007-06-30-00.37.30.124670'
GROUP BY C_INCIDENT_TYPE
ORDER BY 2
WITH UR
The only statement difference between the two queries is: WHERE SUBSTR(I_USER,7,2) NOT IN 'AD','WF','F5') (The other query says 'IN')
That is my question... Thank You!
4 4192
I want my output in two columns like this:
C_INCIDENT_TYPE \ TOTAL COUNT
How do I combine my two queries to get result.
First Query
SELECT C_INCIDENT_TYPE, COUNT (*)
FROM TABLE_AUDIT
WHERE SUBSTR(I_USER,7,2) IN ('AD','WF','F5')
AND SUBSTR(I_IMAGE_COPY,12,8) > '00000000'
AND SUBSTR(I_IMAGE_COPY,12,8) < '99999999'
AND D_H_STAMP BETWEEN '2007-06-01-00.37.30.124670' AND
'2007-06-30-00.37.30.124670'
GROUP BY C_INCIDENT_TYPE
ORDER BY 2
WITH UR
Second Query
SELECT C_INCIDENT_TYPE, COUNT (*)
FROM TABLE_AUDIT
WHERE SUBSTR(I_USER,7,2) NOT IN 'AD','WF','F5')
AND SUBSTR(I_IMAGE_COPY,12,8) > '00000000'
AND SUBSTR(I_IMAGE_COPY,12,8) < '99999999'
AND D_H_STAMP BETWEEN '2007-06-01-00.37.30.124670' AND
'2007-06-30-00.37.30.124670'
GROUP BY C_INCIDENT_TYPE
ORDER BY 2
WITH UR
The only statement difference between the two queries is: WHERE SUBSTR(I_USER,7,2) NOT IN 'AD','WF','F5') (The other query says 'IN')
That is my question... Thank You!
How do you want to combine the queries? The two conditions contradict so you can't get data that satisfies both conitions.
How do you want to combine the queries? The two conditions contradict so you can't get data that satisfies both conitions.
I understand that the two conditions contradict each other. My goal is to get the output so it looks like this.
Therefore output will have three columns
C_INCIDENT_TYPE | COUNT (From first Query | COUNT (from Second Query |
| | |
Would I use a join to run the query? Just asking?
Thank You!
I understand that the two conditions contradict each other. My goal is to get the output so it looks like this.
Therefore output will have three columns
C_INCIDENT_TYPE | COUNT (From first Query | COUNT (from Second Query |
| | |
Would I use a join to run the query? Just asking?
Thank You!
I get what you're talking about now. I don't think joining the queries is the proper way of doing it. I'd suggest doing a little bit of arithmetic with it. If you have n records and your first query returns a records, then shouldn't your second query return n - a records?
Thanks, I will look into that more...
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Chris Lutka |
last post by:
I've been racking my brains all day over this. And I'm not the best
at SQL either.
I need a query that will produce the following results:...
|
by: MostlyH2O |
last post by:
Hi Folks,
I have a complex query that references a sub-query. It works fine when I
call a sub-query from the main query (using design vew), but when I try to
embed the SQL text of the...
|
by: Jason Gyetko |
last post by:
Is there any way to combine these two queries into one? I have tables
Item_Master & Kit_Master which are the source tables. Query 2 is using
both Item_Master (table) & qryKit1 (query) &...
|
by: MackTheKnife |
last post by:
I have the following 3 SQL statements that need to be combined, if
possible. The output of one feeds the input of the next. I need to view
all of the defined output fields (the output needs to be...
|
by: Pythor |
last post by:
Hi,
I need to data from several input fields, and treat them as if
they were all the same field. I'm not describing this well, so I'll
give an example:
I have a table like this:
Name ...
|
by: |
last post by:
I have query1 where I set a date range. Query2 is a crosstab query and is based on query1. I don't want the queries to be saved in the mdb but I do want them to be run in VBA using a querystring. If...
|
by: MLH |
last post by:
Consider having tblCorrespondence, then copying & pasting
it to tblCorrespondence1 - such that they are identical. Then
consider the following UNION SELECT statement...
SELECT...
|
by: csolomon |
last post by:
Hello:
I am using two queries to get one result set. The issue is, I return no data when I combine them into one query. I have listed both queries, as well as the 3rd query that shows them...
|
by: bips2005 |
last post by:
i have got two queries,
$sql1 = "select cust_id from customer where comp_name = '$compname'";
$result = $DB->query($sql1);
$result->fetchInto($row);
$sql = "select expirydate from...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
| |