Hi all.
I have a system which operates on Windows MSSQL.
It is used for registering Suppotr requests. The system works with different Tables inside a Database.
One of the tables is for new support calls , another table is for additions to a support call , call_no being the linked cell.
I'm using Excell to pull the information from MSSQL with queries.
First query for the logged support calls by user : - SELECT LOGGED_CALLS.LOGGED_BY, CALL_CATEGORIES.DESCRIPTION, LOGGED_CALLS.DATE_LOGGED, LOGGED_CALLS.CALL_NO, LOGGED_CALLS.CALL_DESCRIPTION, LOGGED_CALLS.CALL_DURATION
-
FROM iesm_support.dbo.CALL_CATEGORIES CALL_CATEGORIES, iesm_support.dbo.LOGGED_CALLS LOGGED_CALLS
-
WHERE CALL_CATEGORIES.CALL_CATEGORY = LOGGED_CALLS.CALL_CATEGORY AND ((LOGGED_CALLS.LOGGED_BY=64) AND (LOGGED_CALLS.DATE_LOGGED>=? And LOGGED_CALLS.DATE_LOGGED<=?))
-
ORDER BY LOGGED_CALLS.DATE_LOGGED
Second query for the addtional support call by user : - SELECT ADDITIONAL_CALLS.LOGGED_BY, CALL_CATEGORIES.DESCRIPTION, ADDITIONAL_CALLS.CALL_NO, ADDITIONAL_CALLS.DATE_LOGGED, ADDITIONAL_CALLS.CALL_DURATION, LOGGED_CALLS.CALL_DESCRIPTION
-
FROM iesm_support.dbo.ADDITIONAL_CALLS ADDITIONAL_CALLS, iesm_support.dbo.CALL_CATEGORIES CALL_CATEGORIES, iesm_support.dbo.LOGGED_CALLS LOGGED_CALLS
-
WHERE LOGGED_CALLS.CALL_NO = ADDITIONAL_CALLS.CALL_NO AND LOGGED_CALLS.CALL_CATEGORY = CALL_CATEGORIES.CALL_CATEGORY AND ((ADDITIONAL_CALLS.LOGGED_BY=64) AND (ADDITIONAL_CALLS.DATE_LOGGED>? And ADDITIONAL_CALLS.DATE_LOGGED<?))
What I now have is : Query 1 and Query 2 on different Worksheets in Excel.
What I want : Information from both queries on SAME worksheet in Excel.
Is this even possible ? (I was messing around with UNION but couldn't get it working)
And If it is possible , how to do so ?
Your help is much appriciated , as I'm not an SQL tech , just a support tech ;)
Peter
6 3081
I am not an Excel programmer but I am familiar with basic SQL rules.
First I changed position of columns to match them in both queries which is important.
Second I put order by at the end.
Try this:
[PHP]SELECT LOGGED_CALLS.LOGGED_BY, CALL_CATEGORIES.DESCRIPTION, LOGGED_CALLS.CALL_NO,
LOGGED_CALLS.DATE_LOGGED, LOGGED_CALLS.CALL_DURATION, LOGGED_CALLS.CALL_DESCRIPTION,
FROM iesm_support.dbo.CALL_CATEGORIES CALL_CATEGORIES,
iesm_support.dbo.LOGGED_CALLS LOGGED_CALLS
WHERE CALL_CATEGORIES.CALL_CATEGORY = LOGGED_CALLS.CALL_CATEGORY
AND ((LOGGED_CALLS.LOGGED_BY=64)
AND (LOGGED_CALLS.DATE_LOGGED>=? And LOGGED_CALLS.DATE_LOGGED<=?))
UNION
SELECT ADDITIONAL_CALLS.LOGGED_BY, CALL_CATEGORIES.DESCRIPTION, ADDITIONAL_CALLS.CALL_NO,
ADDITIONAL_CALLS.DATE_LOGGED, ADDITIONAL_CALLS.CALL_DURATION, LOGGED_CALLS.CALL_DESCRIPTION
FROM iesm_support.dbo.ADDITIONAL_CALLS ADDITIONAL_CALLS,
iesm_support.dbo.CALL_CATEGORIES CALL_CATEGORIES,
iesm_support.dbo.LOGGED_CALLS LOGGED_CALLS
WHERE LOGGED_CALLS.CALL_NO = ADDITIONAL_CALLS.CALL_NO
AND LOGGED_CALLS.CALL_CATEGORY = CALL_CATEGORIES.CALL_CATEGORY
AND ((ADDITIONAL_CALLS.LOGGED_BY=64)
AND (ADDITIONAL_CALLS.DATE_LOGGED>? And ADDITIONAL_CALLS.DATE_LOGGED<?))
ORDER BY 4[/PHP]
Hope it helps.
Good Luck.
Tnx for helping.
The first step seems logical to me so i've rewritten the Excel queries, both same ordering now.
But when trying your code it displays :
[]
Microsoft Query
Parameters are not allowed in queries that can't be displayed graphically
<OK>
[]
While I was trying to get it going , I also got this error everytime I changed the query.
Peter
It is comming from these lines:
[PHP]AND (LOGGED_CALLS.DATE_LOGGED>=? And LOGGED_CALLS.DATE_LOGGED<=?))
AND (ADDITIONAL_CALLS.DATE_LOGGED>? And ADDITIONAL_CALLS.DATE_LOGGED<?))
ORDER BY 4 [/PHP]
Remove thhem and try again.
Tnx but again no go.
When I copy the PHP Code from the Code Block it has a very weird layout (too much spaces and returns ..)
I will dig further , as I cannot get a simple Query from both Tables to display all the wanted information. (I.e in my two excel sheets I get in total 20 results , while the simple query return only 16 results)
Peter
Try this:
SELECT LOGGED_CALLS.LOGGED_BY, CALL_CATEGORIES.DESCRIPTION, LOGGED_CALLS.CALL_NO,
LOGGED_CALLS.DATE_LOGGED, LOGGED_CALLS.CALL_DURATION, LOGGED_CALLS.CALL_DESCRIPTION,
FROM iesm_support.dbo.CALL_CATEGORIES CALL_CATEGORIES,
iesm_support.dbo.LOGGED_CALLS LOGGED_CALLS
WHERE CALL_CATEGORIES.CALL_CATEGORY = LOGGED_CALLS.CALL_CATEGORY
AND ((LOGGED_CALLS.LOGGED_BY=64)
UNION All
SELECT ADDITIONAL_CALLS.LOGGED_BY, CALL_CATEGORIES.DESCRIPTION, ADDITIONAL_CALLS.CALL_NO,
ADDITIONAL_CALLS.DATE_LOGGED, ADDITIONAL_CALLS.CALL_DURATION, LOGGED_CALLS.CALL_DESCRIPTION
FROM iesm_support.dbo.ADDITIONAL_CALLS ADDITIONAL_CALLS,
iesm_support.dbo.CALL_CATEGORIES CALL_CATEGORIES,
iesm_support.dbo.LOGGED_CALLS LOGGED_CALLS
WHERE LOGGED_CALLS.CALL_NO = ADDITIONAL_CALLS.CALL_NO
AND LOGGED_CALLS.CALL_CATEGORY = CALL_CATEGORIES.CALL_CATEGORY
AND ((ADDITIONAL_CALLS.LOGGED_BY=64)
ORDER BY 4
Thanks all for helping.
But the company who made the program have included some reports now into the application.
With one of the reports I can see a users activity. With another report I can see the total activity , by day , week or even month
You're help is/was much appriciated !!
Pete
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Steve Jorgensen |
last post by:
Hi all,
I'm working on the schema for a database that must represent data about stock
& bond funds over time. My connundrum is that, for any of several dimension
fields, including the fund name...
|
by: Jamie Pittman via AccessMonster.com |
last post by:
I have two tables with 5000 entries on them. One is based for regular time
with several variables example (employee name, date,time in and out, code,
customer, building) I have another table that...
|
by: Reidar Jorgensen |
last post by:
I have several Access databases, identical in structure, but different data. Is there an
easy way to combine them all into one database? There are six tables, I just want the
data from all...
|
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: Will |
last post by:
Hi all
I have a table, where there's AutoID, Name of Person (looked up from
tblPerson), Name of Dispute (looked up from tblDispute), Date, Details
(Memo). What I have is another table that need...
|
by: PlayHard |
last post by:
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 (*)
|
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: 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: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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,...
| |