I am currently trying to build and delete references in j805. By:
jd 'ref tableA colA tableB colB'
I can create references. But I have problems when trying to delete it. I tried:
jd 'drop ref tableA colA tableB colB'
jd 'dropdynamic ref tableA colA tableB colB'
jd 'delete ref tableA colA tableB colB'
Or even the code in j804:
jd 'dropdynamic reference tableA colA tableB colB'
But those lines of code did not work. Anyone gets an idea how to delete the references? Thanks!
Jd release 4.1 simplified links between database tables (refs). The following answers your question assuming 4.1.
jd'list version'
4.1
jd'ref f a g b'
jd'info ref'
┌─────┬───────────┐
│table│column │
├─────┼───────────┤
│f │jdref_a_g_b│
└─────┴───────────┘
jd'dropcol f jdref_a_g_b'
Related
I was actually trying to delete the data from the Delta table.
When i run the below query, I'm getting data around 500 or 1000 records.
SELECT * FROM table1 inv
join (SELECT col1, col2, col2, min(Date) minDate, max(Date) maxDate FROM table2 a GROUP BY col1, col2, col3) aux
on aux.col1 = inv.col1 and aux.col2 = inv.col2 and aux.col3 = inv.col3
WHERE Date between aux.minDate and aux.maxDate
But when i try to delete that 500 records with the below query I'm getting error with syntax.
DELETE FROM table1 inv
join (SELECT col1, col2, col2, min(Date) minDate, max(Date) maxDate FROM table2 a GROUP BY col1, col2, col3) aux
on aux.col1 = inv.col1 and aux.col2 = inv.col2 and aux.col3 = inv.col3
WHERE Date between aux.minDate and aux.maxDate
Please someone help me here.
Thanks in advance :).
Here is the sql reference:
DELETE FROM table_identifier [AS alias] [WHERE predicate]
You can't use JOIN here, so expand your where clause according to your needs.
Here are some examples:
DELETE FROM table1
WHERE EXISTS (SELECT ... FROM table2 ...)
DELETE FROM table1
WHERE table1.col1 IN (SELECT ... FROM table2 WHERE ...)
DELETE FROM table1
WHERE table1.col1 NOT IN (SELECT ... FROM table2 WHERE ...)
I got two tables below:
And I want to create a query to combine them like below:
But unsuccessfully I got something like this:
Some data for "value1" duplicated
How can I solve this?
Is there any function that can have "value1" for the first "no." only?
Thank you.
You can do this by using a subquery to prepare the data.
It seems you want only the rows with the lowest Sub no to join, so we'll first select that:
SELECT [No], Value2
FROM Table2 m
WHERE
EXISTS(
SELECT 1
FROM Table2 s
WHERE s.[No] = m.[No]
HAVING MIN(s.sub_no) = m.sub_no
)
Then, integrate this into your main query:
SELECT *
FROM Table1
INNER JOIN (
SELECT [No], Value2
FROM Table2 m
WHERE
EXISTS(
SELECT 1
FROM Table2 s
WHERE s.[No] = m.[No]
HAVING MIN(s.sub_no) = m.sub_no
)
) AS T2 ON T1.[No] = T2.[No]
Table A having 20 records and table B showing 19 records. How to find that one record is which is missing in table B. How to do compare/subtract records of these two tables; to find that one record. Running query in Apache Superset.
The exact answer depends on which column(s) define whether two records are the same. Assuming you wanted to use some primary key column for the comparison, you could try:
SELECT a.*
FROM TableA a
WHERE NOT EXISTS (SELECT 1 FROM TableB b WHERE b.pk = a.pk);
If you wanted to use more than one column to compare records from the two tables, then you would just add logic to the exists clause, e.g. for three columns:
WHERE NOT EXISTS (SELECT 1 FROM TableB b WHERE b.col1 = a.col1 AND
b.col2 = a.col2 AND
b.col3 = a.col3)
How come this does not work and what is a workaround?
DELETE FROM
(SELECT
PKID
, a
, b)
Where a > 1
There is a Syntax Error at "(".
DELETE FROM (TABLE) where a > 1 gives the same syntax error.
I need to delete specific rows that are flagged using a rank function in my select statement.
I have now put a table immediately after the DELETE FROM and put WHERE restrictions on the DELETE and in a small series of self-joins of the table.
DELETE FROM TABLE1
WHERE x IN
(SELECT A.x
FROM (SELECT x, r1.y, r2.y, DENSE_RANK() OVER (PARTITION by r1.y, r2.y ORDER by x) AS RANK
FROM TABLE2 r0
INNER JOIN TABLE1 r1 on r0.x = r1.x
INNER JOIN TABLE1 r2 on r0.x = r2.x
WHERE r1.y = foo and r2.y = bar
) AS A
WHERE A.RANK > 1
)
I have a two column list:
SystemA, tableA
SystemA, tableB
SystemA, tableC
SystemA, tableD
SystemB, tableA
SystemB, tableC
SystemB, tableD
SystemC, tableA
I need to generate a cross reference matrix listing tables (no dups) and which systems reference them.
Here is what it should look like:
SystemA SystemB SystemC
tableA x x x
tableB x
tableC x x
tableD x x
Is this something that can be done in Excel or do I have to write code to do it?
You need a simple pivot table. Make some search on google.
Following wizard is very simple. You have just to drag fields in the right place (table on row field and system on both column field and data field).