Ok, let me see if I can explain this clearly. What I'm trying to do is generate a query that looks for duplicate start times. The caveat here is there are certain character strings that have to be present for it to be considered a duplicate. Here is the existing query I have: - SELECT AL2.PS, AL2.ASSETS, AL2.PT, AL2.NP, AL2.NN, AL2.AS, AL2.PR, AL2.CH1, AL2.AT, AL2.AD, AL2.PC, AL2.PE, AL2.STAT, AL2.SYS, AL2.BD, AL2.LOC, AL2.IR FROM MYDB AL2
-
WHERE (PS >= CAST(
-
FLOOR( CAST( GETDATE() AS FLOAT ) )
-
AS DATETIME
-
)+1) AND (PS < CAST(
-
FLOOR( CAST( GETDATE() AS FLOAT ) )
-
AS DATETIME
-
)+14) AND ST <> 'CL';
Ok, now the duplication will be based on AL2.PS and the AL2.ASSETS field must contain certain codes in it to be considered a duplicate.
Example:
If record 1 has a PS = 2010-11-15 15:30:00 and has an ASSET code of JPB, find any records that match that time in this table. The idea is I'm looking for duplicated records in the same table. I have been working on this and I am stumped.
5 1452
How about : -
SQL> ed
-
Wrote file afiedt.buf
-
-
1 with t as (SELECT '2010-11-15 15:30:00' ps,'JPB' asset from dual
-
2 union all select '2010-11-15 15:30:00','JPB' from dual
-
3 union all select '2010-11-15 15:30:32','JPB' from dual)
-
4 select ps,asset,COUNT(*) cnt
-
5 FROM t
-
6 GROUP BY ps,asset
-
7* HAVING COUNT(*) > 1
-
SQL> /
-
-
PS ASS CNT
-
------------------- --- ----------
-
2010-11-15 15:30:00 JPB 2
-
-
SQL>
-
-
Thank you, I will give that a shot! :)
What is Dual supposed to be? Got a large result dating back to 2009. I want only 14 days of data into the future.
Can you post what you are trying?
Btw, Dual is a dummy table that I used to create dummy data becauase I dont have a table that you are using.
Ok, what I am trying to accomplish is as follows:
based on a sub query that finds certain items that must run without interruption, I want to have a query that will return results that would cause a time conflict. The subquery I am using is: -
SELECT START, END, NUMBER, CHAR1, PROJECT, DEPT, CATEGORY
-
from MyDB
-
WHERE START between (CAST(FLOOR( CAST( GETDATE() AS FLOAT ) ) AS DATETIME)+1)
-
AND (CAST(FLOOR( CAST( GETDATE() AS FLOAT ) ) AS DATETIME)+7)
-
AND CATEGORY = 'MAIN'
-
AND CHAR1 = 'YES'
-
Now, the prime difference is the ones I'm looking for would be CHAR1 as NO or NULL. The conflict would be related to the duration. None of the non-char1 tasks can be ran during the duration. Here is a sample result set: -
START END NUMBER CHAR1 PROJECT DEPT CATEGORY
-
2010-11-20 23:00:00 2010-11-21 04:00:00 18688 YES Project1 DEPT1 MAIN
-
2010-11-21 23:00:00 2010-11-22 00:00:00 19933 YES Project2 DEPT2 MAIN
-
2010-11-19 00:00:00 2010-12-17 00:00:00 25652 YES Project3 DEPT3 MAIN
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Jerry |
last post by:
Hi,
Access 2003. I would like to query specific dates or years. I need to
be able to selct the dates in a query, ie aug 12 2004, aug 11th 2004,
or 2001, 2002 and 2003.
Any help is most appreciated
|
by: carrionk |
last post by:
Hi,
I have created a Subform which SourceObject is a parameter query.
This is the Query:
Qry Name:80IsscomProduct
SELECT *
FROM Isscomp28
WHERE Like ;
|
by: YuanYuan |
last post by:
Thank you so much, guys. I really appreciate that.
>-----Original Message-----
>Hi, I am wondering if there is a nice way to elimate
>duplicated values in an array, just like the "unique"
>algorithm in STL.
>
>eg. original array is {1, 1, 2, 3, 3, 4);
> the result is (1, 2, 3, 4)
>
|
by: mkjets |
last post by:
I have worked for hours on trying to find a solution and have not
figured it out. I am working in Access 2003. I need to create a query
that takes values from 1 table and displays them in multiple fields. I
don't have the option of changing the structure of the existing tables
because I am importing them from a separate data source on a regular
basis. I also need to use a query instead of a form because I then
need to be able to export...
|
by: bubbles |
last post by:
Newbie transiting from VBA to TSQL, using SQL Server 2005 Enterprise:
Need help to do this:
Open Table_A
WITH TableA
DO UNTIL .EOF
Read value from TableA.ColumnA
Run SQL Statement on TableB based on value
| |
by: Pete |
last post by:
I need to create a single query (Not a SQL query) against a single
table that counts the number of records in the table, where the single
field "tmp" contains specific string values
If the field contains "AAA" the count is X.
if the field contains "CCC" the count is Y.
if the field contains "Stop" then count is Z.
I have tried several ways and can not seem to get any where. I get
the same count for all string values. Can some one...
|
by: gerrybytes |
last post by:
Is the following a vaild query, or does any one have any suggestion on how to change it to get the correct info i'm looking for?
$Engineer = $_POST;
$Ref_No = $_POST;
$query = "INSERT INTO engineer (Ref_No,Title,Forename,Surname,Email,Branch,Message,Severity,Engineer)
VALUES('$Engineer')
SELECT Ref_No,Title,Forename,Surname,Email,Branch,Message,Severity FROM new_fault
WHERE ref_no='$Ref_No'";
|
by: asp2 |
last post by:
I have a cursor inside a program unit in Oracle Forms 6
and its supposed to get one row from this cursor ..
but in some values (only some and others not) it gets the same row twice (duplicated) in cursor's active set , I have checked on ROWNUM and it confirmed same row retrieval !!
I checked the table for duplicated values but it returned non , also the selected column is the primary key !!!!
DECLARE
CURSOR C IS
SELECT...
|
by: Suevans |
last post by:
I've written a basic query which has a calculated field
Amount: -
The query works fine. Sometimes it will not have anything to show, this is correct, it is for unreconciled transactions. When I use this query in a report if there are transactions it shows them perfectly. However, if there are no transactions it returns #Error.
I have read tonnes of information on IF, IIF, null values and more but I must be doing something basically...
|
by: Marcin W |
last post by:
Hi,
I have following problem. I have to run a query where one of the result fields should be within range of values I got from different table.
Query 1
select column_x from table1 where filed_x = 'Y'
this query gives me 33 different alphanumeric values
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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: 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: 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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |