Hey Carl,
I think this is basically what I want, but a little scaled down.

The problem is I can't get my sql to compile.

I have tried the following.
EXEC SQL
with tmp as(SELECT coord, MIN(cordate) AS open, MAX(cordate)
as done FROM cutsopnn00 GROUP BY coord)
SELECT * FROM cutsopnn00 a
join tmp b on
a.csord = b.coord AND open > 0 AND done > 0 ;

but I get an error saying "INTO clause missing" on the line that stats with 'with'

I don't see any examples using an into clause.

I also found this example so I tried it and get the same error.

with cte as (
select field1, min(field2) as minfield2
from michael/myduptable
group by field1)
Select a.*
from someothertable a
join cte b on a.field1 = b.field1 and a.field2 = b.minfield2

do you see what I have wrong?

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Carel Teijgeler
Sent: Thursday, February 23, 2012 12:35 PM
To: midrange-l@xxxxxxxxxxxx
Subject: Re: help needed with sql statement

Mike,

What about:

WITH tmp AS(SELECT order, MIN(repairdate) AS open, MAX(repairdate) as done
FROM fileb GROUP BY order)

SELECT a.order. b.open, b.done FROM filea a, tmp b WHERE a.order = b.order
AND open > 0 AND done > 0
UNION
SELECT a.order. b.open, b.done FROM filea a, tmp b WHERE a.order =
b.order AND open = 0 AND done > 0
UNION
SELECT a.order. b.open, b.done FROM filea a, tmp b WHERE a.order = b.order
AND open = 0 AND done = 0

You can also see how long it took for the repairs when open and done have
different dates.

Regards,
Carel Teijgeler

*********** REPLY SEPARATOR ***********

On 23-2-2012 at 16:58 Smith, Mike wrote:

I have 2 files.

FILEA and FILEB

Scenario. I am trying to create a view over 2 files that show me OPEN,
REPAIRED or ALL.
Open is where a order in FILEB has at least 1 record that has no repair
date.
Repaired is when a order in FILEB has ALL records with a Repair date.
The ALL part I got :)

Both have order number.
FILEA(ORDER)
FILEB (ORDER, REPAIRDATE)
FILEB can have multiple records per Order number

I've been struggling with this all morning.

Thanks for any help

Mike
NOTICE: This message, including any attachment, is intended as a
confidential and privileged communication. If you have received this
message in error, or are not the named recipient(s), please immediately
notify the sender and delete this message.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.



-----
Geen virus gevonden in dit bericht.
Gecontroleerd door AVG - www.avg.com
Versie: 10.0.1382 / Virusdatabase: 2113/4823 - datum van uitgifte:
02/21/12



--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.

NOTICE: This message, including any attachment, is intended as a confidential and privileged communication. If you have received this message in error, or are not the named recipient(s), please immediately notify the sender and delete this message.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.