I have DB with following schema
I want to conduct a query to find all the vertexes which have only 'A' and dont't have 'B' as their descendant (c.out('RepositoryEdge').out('InfoEdge'))
For Specific example only vertex #33:53 satisfies this condion
How Should i Conduct My Query ?
Thanks in advance
Try this:
select from <class-name> where #rid not in (select in("InfoEdge").in("RepositoryEdge") from #42:0) and #rid in (select in("InfoEdge").in("RepositoryEdge") from #41:5)
Hope it helps
Regards
Related
Is there a way to do select count(distinct column1) from table with jpa query method not with query annotation?
I know I can do select count(distinct column1) from table where column2 = :column2 by long countDistinctColumn1ByColumn2(:column2).
I've searched official documents and tried some tests but couldn't find a way, thanks in advance.
This is not supported by Spring Data JPA.
The documentation can be found here https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.query-methods
I have native query like this
SELECT sample.api_name,
sample.hitcount,
r.unit_rate*sample.hitcount AS amnt
FROM
(SELECT u.api_name AS api_name,u.tenant_id,
u.count AS hitcount
FROM tableA u
WHERE u.tenant_id = :tenant
AND u.time_stamp BETWEEN :dateFrom AND :dateTo
GROUP BY u.api_name,
u.tenant_id) AS sample
LEFT JOIN tableB r ON sample.api_name = r.api_name
AND sample.tenant_id =r.tenant_id
The values "tenant,dateFrom,dateTo" values are providing by using #Param tag.
I have tried to convert to the jpql query in spring data jpa.
But by seeing in some reference documents i came to know that the
Jpql inner queries are not supported in the FROM clause.
is that my point correct or not. If not Please help me to write in JPQL if my point is correct please help to write in Criteria api.
I am trying to write a simple statement in my where clause but I don't believe I have the syntax right. The query looks to search whether these ID's are in this column but I am not sure if I can use IN twice in the same line? Could anyone please provide some feed back. Thanks!
WHERE... AND (tableA.ColumnA in LEN(LTRIM(RTRIM(TableB.ColumnB))) in (5,7) )
I am getting some syntax errors near the second IN and can't figure out if this is the correct way to approach this?
When you use IN with a column, it needs to be a sub-select, but here is a correct way you can do it (Wes's sub-select still has the same syntax error):
WHERE... AND (tableA.ColumnA in (
SELECT ColumnB FROM TableB WHERE LEN(LTRIM(RTRIM(TableB.ColumnB))) in (5,7)
))
Try using a subquery instead.
WHERE... AND (SELECT TA.ColumnA
FROM TableA TA
WHERE TA.ColumnA IN LEN(LTRIM(RTRIM(TABLEB.ColumnB))) IN (5,7)
using join
join TableB
on TableB.ColumnB = tableA.ColumnA
and LEN(LTRIM(RTRIM(TableB.ColumnB))) in (5,7)
I'm attempting to count the number of instances of a value that includes "WMH" and then sort the result (like a "Top 10 Most Popular" list). But I am getting the aggregate function error.
Any thoughts about this:
SELECT TrackingLabel, Count(TrackingLabel) AS CountOfTrackingLabel
FROM CTM_Export
GROUP BY TrackingLabel
HAVING TrackingLabel Like 'WMH'
Having clause refers to the same columns/aggregate functions used in select list, for example
SELECT column_name, aggregate_function(column_name)
FROM table_name
GROUP BY column_name
HAVING aggregate_function(column_name) operator value;
with regards to your query, if I understand your requirements, you could rewrite the query like:
SELECT TrackingLabel, Count(TrackingLabel) AS CountOfTrackingLabel
FROM CTM_Export
WHERE TrackingLabel Like 'WMH'
GROUP BY TrackingLabel;
regards, Michael
I have a query to select names of employee start with 'y', then my query would be
SELECT EMP_NM FROM EMP
WHERE EMP_NM LIKE'Y%'
Say for example
I need to retrieve names of employee
names start with both 'y' and 'z', do
we have anything to suffice my
requirement? It's something like using
OR with LIKE, correct?
Your time and responses are highly appreciated.
WHERE EMP_NM LIKE 'Y%' OR EMP_NM LIKE 'Z%'
or, not sure if DB2 supports this (not even sure I have right link to documentation...)
WHERE EMP_NM LIKE '[YZ]%'