Hi,
I want my query to go through all the employee hours and list the associated rates for each record. This means going through Eng_Costing and linking to Eng_PrjGrds (matching Project and Grade), then linking to Eng_Rate using Rate ID. -
SELECT Eng_Phase.Phs_MainPrj, Eng_Costing.CST_Grade, Eng_Costing.CST_Date, Eng_Costing.CST_Norm_H, Eng_Costing.CST_OT_H, Eng_Costing.CST_OTX_H, Eng_Rate.RT_Norm, Eng_Rate.RT_OT, Eng_Rate.RT_OTX
-
-
FROM Eng_Rate INNER JOIN Eng_PrjGrds ON Eng_Rate.RT_ID = Eng_PrjGrds.PRJGRD_RateID, Eng_Costing INNER JOIN Eng_Phase ON Eng_Costing.CST_Phase = Eng_Phase.Phs_Auto
-
-
WHERE (((Eng_Rate.RT_DtFrm)<=[eng_costing].[cst_date]) AND ((Eng_PrjGrds.PRJGRD_Prj)=[eng_phase].[phs_mainprj]) AND ((Eng_PrjGrds.PRJGRD_Grade)=[eng_costing].[cst_grade]) AND ((Eng_Costing.CST_OverHead)=False))
-
-
ORDER BY Eng_Phase.Phs_MainPrj, Eng_Rate.RT_DtFrm DESC;
-
My problem is this, Eng_Costing has around 3500 records and the query returns about 6000. It is caused by the value RateID having duplicate entries in the Eng_Rate table, these duplicate entries are necessary to allow the continuous updating of Rates charged to customers.
I need the query to only return one Eng_Rate record for each Eng_Costing record, the Eng_Rate record I want is the first one found.
If anyone has any ideas...please feel free to suggest them.
I thought about perhaps using 'Distinct' or 'Top 1', but obviously either i'm putting them in the wrong place or they just aren't suitable for this.
I'm using Access 2003 on XP.
3 1423
Nevermind folks....solved
I changed the query to call a function which locates the rate for each record, not quite what I was originally hoping for but.....it works :)
nico5038 3,080
Recognized Expert Specialist
For the requirement:
"I need the query to only return one Eng_Rate record for each Eng_Costing record, the Eng_Rate record I want is the first one found."
You could have used a GroupBy query with the "First" option for the value needed.
Nic;o)
thanks Nico
I'll give it a try when I get a chance.....it might speed up the query a bit.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Kingdom |
last post by:
I'm using this script to dynamicaly populate 2 dropdowns and dispaly the
results. Choose a component type from the first drop down, lets say
'car' and the second box will list all the car 'manufacturers' and the
display will then provide all the rest of the info from the other fields.
I need to eliminate all the duplicates in the First Drop Down as it
currently displays an entry for every record, many are identical, I might
have over...
|
by: George |
last post by:
Hi,
I am trying to write a query in Oracle which I have not done before,
and are having some difficulty getting my result.
Please check my query and my results.
select max(note.datetime),
acgr.group_code,
bank.local_acc_no,
bank.short_name,
|
by: sks |
last post by:
Hi,
I have a products table which apart from other things has a column called
manufacturer. I want to run a query that returns x number of products PER
manufacturer for each manufacturer that matches some criteria.
table::products
--------
id
|
by: Tom Leylan |
last post by:
Help :-) I can't see how this should be laid out!
Consider the scenario of a car rental company. They have "cars" and "lots"
(nationwide) and "customers." So far it is easy to query each of these. A
car is rented by a customer so there would be say a "rentals" table. A car
is rented and returned over and over so there would be many rentals for each
car. One thing to remember is that the car isn't assigned to a specific lot
so...
|
by: k k |
last post by:
Hi,
The following query has failed to return all the records.
SELECT b.Account_desc, b.Account,
IIf(a.source_type = 'LY01', a.CSPL_CSPL,0), IIf(a.source_type = 'LY01',
a.CSPL_CMS,0), IIf(a.source_type = 'LY01', a.CSPL_CMM,0),
IIf(a.source_type = 'LY01', a.CSPL_CMT,0) from Actual_data_final a right
outer join Actual_account_Tbl b on a.Account_desc = b.Account_desc
| |
by: Development - multi.art.studio |
last post by:
Hello everyone,
i just upgraded my old postgres-database from version 7.1 to 7.4.2.
i dumped out my 7.1 database (with pg_dump from 7.1) as an sql-file with
copy-commands and to one file using insert-statements.
after initalizing and starting postgres 7.4 on a different port and
datadirectory, i tried to import the sql-dump with the copy statements.
this import fails, but importing the dump-file with inserts took a long
time but was...
|
by: mpar612 |
last post by:
Hi everyone,
The code posted below retrieves all of the rows from a database table.
It paginates them by limiting to 20 results per page. It is supposed
to print 5 rows of results with 4 results per row. Everything works
fine, except the first row returned from the database is never printed.
It doesn't matter how the results are ordered or how many rows are in
the db, the first row that is supposed to be printed is not printed.
Does...
|
by: Hexman |
last post by:
Hello All,
How do I limit the number of detail records selected in a Master-Detail set using SQL?
I want to select all master records for a date, but only the first 3 records for the details (based on the primary key of the detail record). I've
been trying with "TOP 3", but can't get anywhere. Using Access 2000.
Something like:
SELECT t1.*, TOP 3 t2.*
|
by: JustinCarmony |
last post by:
I'm using a DataAdapter to fill a DataSet to display a list of items
in a custom way. I'm not using the GridView or any server controls
like that.
This is my code:
<code>
SqlConnection sqlConn =
DatabaseControl.Database.GetConnection(Globals.dbConn);
SqlCommand cmdTitles = new SqlCommand();
cmdTitles.CommandText = "SelectTitlesByCategory";
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |