Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
The following query
SELECT JOB_TYPE, CLASS, JOB_RUN_START, JOB_RUN_FINISH, JOB_STATUS, JOB_PID FROM
(SELECT * FROM ARCHIVE_JOBS ORDERBY JOB_RUN_START ASC ) WHERE ROWNUM <=6;
yields to an error:
ERROR at line 1: ORA-00907: missing right parenthesis
Anybody know why?
It's order by and you missed aliasing your subquery. I used X as alias name
SELECT JOB_TYPE, CLASS, JOB_RUN_START, JOB_RUN_FINISH, JOB_STATUS, JOB_PID
FROM
(
SELECT * FROM ARCHIVE_JOBS
ORDER BY JOB_RUN_START ASC
) X
WHERE ROWNUM <=6;
try to replace ORDERBY by ORDER BY
ORDERBY is not a keyword, so it's considered by mysql as in the FROM part of the query (i.e. a table), and table list should be separated by ,
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
select count(*) as distinctname from
(select distinct nationalityname from dbo.profile)
Use an alias for your subqueries
select count(*) as distinctname from
(select distinct nationalityname from dbo.profile) alias_name
or make it simpler like this
select count(distinct nationalityname) from dbo.profile
Just give alias to sub-query
select count(*) as distinctname
from (select distinct nationalityname
from dbo.profile) t -- this is alias
In SQL Server, You need to give alias to sub-queries used in FROM clause.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have a simple question: I would like to know how to display records from my database starting from the second record.
Thank you!
If you have a column that specifies the ordering, the ANSI standard way to do this is:
select t.*
from table t
order by col
offset 1 row;
Try this:
select * from
(select
*,
ROW_NUMBER() over (order by TableId) as rn
from TableName) dane where rn>1
in MSSQL.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Hi I am trying to find duplicates with the same ID. I am not finding all of the duplicates. I would like to find distinct JOIN_FID values, and then duplicate JOIN FID values.
Here is my SQL select statements.
select OBJECTID,
Join_Count,
TARGET_FID,
JOIN_FID,
StrtConcat,
PermID,
Minutes,
FacilityID,
Shape
from
sde.gis.MFD_8_minute_response_ladder
where TARGET_FID
in (
select
JOIN_FID
from
sde.gis.MFD_8_minute_response_ladder
group by
JOIN_FID
having
COUNT(*) > 1
You're missing a closing parenthesis ()), but I assume that's a typo.
I suspect the problem may be that you're comparing two different fields:
where TARGET_FID
in (
select
JOIN_FID
Should that be:
where TARGET_FID
in (
select
TARGET_FID
or
where JOIN_FID
in (
select
JOIN_FID
?
For the query that you added ,an IN subquery can only return one value, so you need something like:
where PermID
in (
select
COUNT(1),
TARGET_FID
making sure you're comparing the right columns.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to use multiple CTEs in my query, but I haven't been able to get it working. The following is an example of what I would like to do:
WITH tbl1 AS
(SELECT *
FROM tblStuff)
WITH tbl2 AS
(SELECT tbl1.fldStuff1 ...
FROM tbl1, tblStuff2)
SELECT *
FROM tbl2
You only need to specify WITH once. Then you can list additional CTEs separated by a comma. E.g.:
WITH cte1 AS
(
...
),
cte2 AS
(
...
)
SELECT ...;
WITH tbl1 AS
(SELECT *
FROM tblStuff),
tbl2 AS
(SELECT tbl1.fldStuff1, tbl1.fldStuff2, tblStuff2.fldStuff1, tblStuff2.fldStuff2
FROM tbl1, tblStuff2)
SELECT *
FROM tbl2
When you use multiple CTEs, no need for the extra WITH, seperate with a comma.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I have a SQL query where I want to order the database on type, order and category. Can I have query having all these three?
select * from t_person where name=xyz order by type,category,order
try this:
Use "" (double quotes) to escape the reserved keyword order
select * from t_person where name='xyz'
order by type,category,"order"
Use double quote for correct query:
select * from t_person where name='xyz' order by type,category,"order"