public inbox for [email protected]
help / color / mirror / Atom feedRe: Syntax error needs explanation
5+ messages / 3 participants
[nested] [flat]
* Re: Syntax error needs explanation
@ 2025-07-14 19:14 David G. Johnston <[email protected]>
2025-07-14 19:19 ` Re: Syntax error needs explanation [RESOLVED] Rich Shepard <[email protected]>
0 siblings, 1 reply; 5+ messages in thread
From: David G. Johnston @ 2025-07-14 19:14 UTC (permalink / raw)
To: Rich Shepard <[email protected]>; +Cc: [email protected]
On Mon, Jul 14, 2025 at 12:12 PM Rich Shepard <[email protected]>
wrote:
> I have the following script:
>
> select c.company_nbr, c.company_name, i.industry,
> from companies as c, industry as i, enforcement as e
> where exists (
> select c.company_nbr, count(e.action_date), sum(e.penalty_amt)
> from e.enforcement
> where c.company_nbr = e.company_nbr
> )
> group by industry
> order by industry;
>
> When I run it psql reports an error:
> psql:companies-with-enforcement-actions.txt:127: ERROR: syntax error at
> or near "company_nbr"
> LINE 1: company_nbr | company_name
> ^
> and I'm not seeing the error. What am I missing?
>
The error indicates your script file is at least 127 lines long and you are
showing like 9...also do you usually name your script files with a .txt
extension?
David J.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Syntax error needs explanation [RESOLVED]
2025-07-14 19:14 Re: Syntax error needs explanation David G. Johnston <[email protected]>
@ 2025-07-14 19:19 ` Rich Shepard <[email protected]>
2025-07-15 05:46 ` Re: Syntax error needs explanation [RESOLVED] Laurenz Albe <[email protected]>
0 siblings, 1 reply; 5+ messages in thread
From: Rich Shepard @ 2025-07-14 19:19 UTC (permalink / raw)
To: [email protected]
On Mon, 14 Jul 2025, David G. Johnston wrote:
> The error indicates your script file is at least 127 lines long and you
> are showing like 9...also do you usually name your script files with a
> .txt extension?
David J.,
Agh! No the filename extension is .sql. But I was using the \o psql option
to write script output to files and mistyped the script name.
Mea culpa!
Many thanks,
Rich
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Syntax error needs explanation [RESOLVED]
2025-07-14 19:14 Re: Syntax error needs explanation David G. Johnston <[email protected]>
2025-07-14 19:19 ` Re: Syntax error needs explanation [RESOLVED] Rich Shepard <[email protected]>
@ 2025-07-15 05:46 ` Laurenz Albe <[email protected]>
2025-07-15 05:55 ` Re: Syntax error needs explanation [RESOLVED] David G. Johnston <[email protected]>
2025-07-15 12:40 ` Re: Syntax error needs explanation [RESOLVED] Rich Shepard <[email protected]>
0 siblings, 2 replies; 5+ messages in thread
From: Laurenz Albe @ 2025-07-15 05:46 UTC (permalink / raw)
To: Rich Shepard <[email protected]>; [email protected]
On Mon, 2025-07-14 at 12:19 -0700, Rich Shepard wrote:
> On Mon, 14 Jul 2025, David G. Johnston wrote:
>
> > The error indicates your script file is at least 127 lines long and you
> > are showing like 9...also do you usually name your script files with a
> > .txt extension?
>
> Agh! No the filename extension is .sql. But I was using the \o psql option
> to write script output to files and mistyped the script name.
>
> Mea culpa!
Apart from that, the subquery seems to be missing a GROUP BY clause.
Yours,
Laurenz Albe
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Syntax error needs explanation [RESOLVED]
2025-07-14 19:14 Re: Syntax error needs explanation David G. Johnston <[email protected]>
2025-07-14 19:19 ` Re: Syntax error needs explanation [RESOLVED] Rich Shepard <[email protected]>
2025-07-15 05:46 ` Re: Syntax error needs explanation [RESOLVED] Laurenz Albe <[email protected]>
@ 2025-07-15 05:55 ` David G. Johnston <[email protected]>
1 sibling, 0 replies; 5+ messages in thread
From: David G. Johnston @ 2025-07-15 05:55 UTC (permalink / raw)
To: Laurenz Albe <[email protected]>; +Cc: Rich Shepard <[email protected]>; [email protected] <[email protected]>
On Monday, July 14, 2025, Laurenz Albe <[email protected]> wrote:
> On Mon, 2025-07-14 at 12:19 -0700, Rich Shepard wrote:
> > On Mon, 14 Jul 2025, David G. Johnston wrote:
> >
> > > The error indicates your script file is at least 127 lines long and you
> > > are showing like 9...also do you usually name your script files with a
> > > .txt extension?
> >
> > Agh! No the filename extension is .sql. But I was using the \o psql
> option
> > to write script output to files and mistyped the script name.
> >
> > Mea culpa!
>
> Apart from that, the subquery seems to be missing a GROUP BY clause.
>
Well, it’s more that an exists subquery with an aggregate generally doesn’t
make sense (it would need to include a having clause at minimum)…it’s not
missing a group by clause, it has aggregates it doesn’t need (they belong
in they belong in the main query where the group clause exists without
aggregates to justify its existence.
David J.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Syntax error needs explanation [RESOLVED]
2025-07-14 19:14 Re: Syntax error needs explanation David G. Johnston <[email protected]>
2025-07-14 19:19 ` Re: Syntax error needs explanation [RESOLVED] Rich Shepard <[email protected]>
2025-07-15 05:46 ` Re: Syntax error needs explanation [RESOLVED] Laurenz Albe <[email protected]>
@ 2025-07-15 12:40 ` Rich Shepard <[email protected]>
1 sibling, 0 replies; 5+ messages in thread
From: Rich Shepard @ 2025-07-15 12:40 UTC (permalink / raw)
To: [email protected]
On Tue, 15 Jul 2025, Laurenz Albe wrote:
> Apart from that, the subquery seems to be missing a GROUP BY clause.
Laurenz,
That was added.
Thanks,
Rich
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2025-07-15 12:40 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-07-14 19:14 Re: Syntax error needs explanation David G. Johnston <[email protected]>
2025-07-14 19:19 ` Re: Syntax error needs explanation [RESOLVED] Rich Shepard <[email protected]>
2025-07-15 05:46 ` Re: Syntax error needs explanation [RESOLVED] Laurenz Albe <[email protected]>
2025-07-15 05:55 ` Re: Syntax error needs explanation [RESOLVED] David G. Johnston <[email protected]>
2025-07-15 12:40 ` Re: Syntax error needs explanation [RESOLVED] Rich Shepard <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox