If I have too many columns and a bunch of them start with similar strings , is there a way in Kusto to select them based on this pattern , such as using wild cards etc ?
e.g. Assuming we have some of the columns like datafield1, datafield2 ... , something like the following would be helpful
mytable | project datafield*
I know that this is not syntactically valid , so is there any workaround for achieving this easily?
project-keep does exactly what you want:
mytable | project-keep datafield*
Related
I have two Kusto tables in the same database, Open_Work_Items and Closed_Work_Items that appear respectively like so:
Item ID | Opened Date
1234 | <DateTime>
Item ID | Closed Date
1234 | <DateTime>
My issue is that I cannot remove work items from Open_Work_Items once the Item ID appears in Closed_Work_Items, but I would still like to query which work items are open. This means I need to find distinct Item IDs Open_Work_Items that do not appear in Closed_Work_Items, but I do not know which Kusto function(s) I can use to do so.
I've looked at Tabular and Scalar Operators, but I'm not understanding how I can combine them to get what I want here. Any help/advice would be appreciated!
Any help would be appreciated!
I think I figured it out:
Open_Work_Items | where Item_ID !in (Closed_Work_Items)
I'm using SQLite to deal with tons of data (like 100gb of data).
I need to seach the value of one column in other table in the fastest way possible.
For example, I need to find the following values of Table 1
[COD]
C62
K801
And then find them in Table 2:
[COD_2]
C60-C63
K80-K81
My desired result is something like:
[COD_1] [COD_2]
C62 C60-C63
K801 K80-K81
Since I have a lot of data, it is inefficient to do something like:
SELECT *
FROM TABLE_1, TABLE_2
WHERE COD_1 LIKE '%' || COD_2 || '%';
Instead, I was trying to do this:
SELECT *
FROM TABLE_1
WHERE COD_1 IN (SELECT COD_2 FROM TABLE_2);
Of course that this doesn't result because the codes are not exactly the sames. Is there a way to search for similar values of one column (something like the LIKE operator) in other table by using IN? Or other way that doesn't cross TABLE_1 and TABLE_2?
Thank you!!!
useful to me.
Based on the small data set shown, and my presumed answer to #Shawn's question (K801 is a typo and is meant to be K80 or K81) I assume the following problem description:
Find a row in COD_2 such that the value in COD_1 is between {value1}-{value2} in COD_2; the - being significant and dependable.
I cannot speak to speed, but I would approach it this way:
SELECT value1, value2
from COD_1,COD_2
where value1 between substr(value2,1,instr(value2,'-')-1) and substr(value2,instr(value2,'-')+1)
The thought being: split the value from COD-2 into a "start" and an "end" value.
I am pretty sure you guys have a simple and fast solution to my problem but my SQL-Skills are limited and I can't figure it out by my self.
So what I have is something like:
Newsgroup: [Name(PK)]
Article: [Id(PK)] [newsgroupName (FK)] [date:Date] [read:Boolean]
What I want know is a query that gives me the Name of each Newsgroup along with the Count of unread articles, Count of all articles and the date of the most recent one...
Is this even possible to archieve in a single Select-Query?
Thank you guys in advance!
You can simply use the appropriate aggregation functions:
SELECT newsgroupName,
SUM(NOT read) AS countUnread,
COUNT(*) AS countAll,
MAX(date) AS mostRecentDate
FROM Article
GROUP BY newsgroupName;
I guess something like this:
SELECT name, COUNT(countUnread) AS countUnread, COUNT(countRead) AS countRead, MAX(mostRecentDateUnread) AS mostRecentDateUnread, MAX(mostRecentDateRead) AS mostRecentDateRead FROM (
SELECT newsgroupName AS name, COUNT(newsgroupName) AS countUnread, 0 AS countRead, MAX(date) AS mostRecentDateUnread, NULL AS mostRecentDateRead
FROM Article
WHERE read = 0
GROUP BY newsgroupName, read
UNION ALL
SELECT newsgroupName AS name, 0 AS countUnread, COUNT(newsgroupName) AS countRead, NULL AS mostRecentDateUnread, MAX(date) AS mostRecentDateRead
FROM Article
WHERE read = 1
GROUP BY newsgroupName, read
)
GROUP BY name
I haven't tried but in theory with some fix it could work.
Kindly review this simple SQLite-fiddle .
If any word in the column ITEM of table TWO matches any word in the column NAME_2 of table ONE, there should be a result(s).
Tried many permutes, yet not sure how to form the query for achieving this. Should the GLOBclause be used instead of LIKE, or perhaps some other wildcard patterns?
Many thanks in advance!
As per my comment, I think you can make use of instr as well. For example:
SELECT * FROM Table1 T1, Table2 T2 where instr(T2.NAME_2,T1.ITEM);
The above should return rows where T2.NAME contains a string = T1.ITEM
I need to select v_col1, from table_x and that column gives me string that i need to put(update) into same
rowid but into diffrent column(h_col2) in sama table table_x - sorry it seems easy but i am beginner....
tabl_x
rowid V_col1, h_col2 etc .....
1 672637263 GVRT1898
2 384738477 GVRT1876
3 263237863 GVRT1832
like in this example i need to put GVRT1898 (update) instead of 672637263 and i need to
go into every row in this table_x and fix -
like next line would be (rowid2 would be GVRT1876 instead of 384738477 :-)
this table has 40000 lines like this and i need to loop for every rowid
THX for your responce Justin - this is a little more complex,
i have this string in h_col and need to take only GVRTnumber out and put into v_col - but it's
hard becouse GVRTnumber is in various place in column see down here....
"E_ID"=X:"GVRT1878","RCode"=X:"156000","Month"=d:1,"Activate"=d:5,"Disp_Id"=X:"4673498","Tar"=X:"171758021";
2"E_ID"=X:"561001760","RCode"=X:"156000","Month"=d:1,"Activate"=d:5,"Disp_Id"=X:"GVRT1898","Tar"=X:"171758021";
h_col column have this number that i want but in various place like somethimes it's in this 600byte column it's in byte nr 156 - sometimes in 287 but the only unique is "GVRT...." how can i take that string and put it to v_col -
Can you show me how to write such SQL pl/sql ?
regards & thanks
It sounds like you just want
UPDATE tabl_x
SET h_col2 = v_col1
Of course, if you do something like this, that implies that one of the two columns should be dropped or the data model needs to get fixed. Having two copies of the same data in each row is a bad idea from a normalization standpoint if nothing else.