Using Kibana Visualizations, how do I make the aggregation ignore case? - kibana

Using Kibana Visualizations, how do I make the aggregation ignore case?
Example Psudo-code:
Select username, min(firstname), min(lastname), count(*)
or
Select username, upper(firstname), upper(lastname), count(*)
If we can't find a way to make the result consistant, we end up with multiple records per user.
This is because some records are uppercase while others are name cased.
Example of what it is:
jBell,JOHN,BELL,32
jBell,John,Bell,55
Example of what it should be:
jBell,John,Bell,87
or
jBell,JOHN,BELL,87

Related

PeopleSoft Query Manager - 'count' function

I'm using the current version of PeopleSoft and I'm using their Query manager. I've built a query that looks at the job table and a customized version of the job table (so I can see future hires). In order to do this I've created a union. Everything works fine, except now I want to do a count of the job codes.
When I put in a count, I get an error. I don't know how to get it to work properly. I also don't really know how to using the 'having' tab.
I've attached some screenshots, including the SQL code.
SQL:
Having tab
You have a criteria in your query:
AND COUNT(*) = A.JOBCODE
Your job codes are string values that uniquely identify a job. It will never be equal to a count.
If you remove that criteria, your query will work:
The bigger issue is, what do you want to count? If your query was simply:
SELECT DEPTID, JOBCODE, COUNT(*)
This will give the count of employees in this department and job code. In your description, you said that you wanted the count of job codes. But each row has JOBCODE on it. The count of job codes on the row is one. What do you really want? The count of job codes in the database? The count of job codes in the result set?
If you want to get anything other than the count of rows within the group, you are not able to put that logic in PeopleSoft Query. You will need to create a view in AppDesigner and then you can add that to the query.

CosmosDB: DISTINCT for only one Column

I have the following query:
SELECT DISTINCT c.deviceId, c._ts FROM c
ORDER BY c._ts DESC
I would like to receive only one pair (c.deviceId, c._ts) per deviceId, but because the c._ts value is distinct for all entries, I am getting all the value-pairs for all deviceIds, with other words my whole DB.
I have tried to use Question: Distinct for only one value as a guide, but I see that CosmosDB does not support GROUP BY.
Is there a way to do this in cosmosDB?
Though it's a common requirement i think,i can't implement it on my side as same as you. The distinct keyword can't work on one single column cross whole query result.
Group by feature is currently in active development for a long period,based on the latest comment in this voice,it is coming soon.
If your need is urgent ,as workaround, you could follow this case to use documentdb-lumenize package which supports Aggregate Functions.

Error with SQLite query, What am I missing?

I've been attempting to increase my knowledge and trying out some challenges. I've been going at this for a solid two weeks now finished most of the challenge but this one part remains. The error is shown below, what am i not understanding?
Error in sqlite query: update users set last_browser= 'mozilla' + select sql from sqlite_master'', last_time= '13-04-2019' where id = '14'
edited for clarity:
I'm trying a CTF challenge and I'm completely new to this kind of thing so I'm learning as I go. There is a login page with test credentials we can use for obtaining many of the flags. I have obtained most of the flags and this is the last one that remains.
After I login on the webapp with the provided test credentials, the following messages appear: this link
The question for the flag is "What value is hidden in the database table secret?"
So from the previous image, I have attempted to use sql injection to obtain value. This is done by using burp suite and attempting to inject through the user-agent.
I have gone through trying to use many variants of the injection attempt shown above. Im struggling to find out where I am going wrong, especially since the second single-quote is added automatically in the query. I've gone through the sqlite documentation and examples of sql injection, but I cannot sem to understand what I am doing wrong or how to get that to work.
A subquery such as select sql from sqlite_master should be enclosed in brackets.
So you'd want
update user set last_browser= 'mozilla' + (select sql from sqlite_master''), last_time= '13-04-2019' where id = '14';
Although I don't think that will achieve what you want, which isn't clear. A simple test results in :-
You may want a concatenation of the strings, so instead of + use ||. e.g.
update user set last_browser= 'mozilla' || (select sql from sqlite_master''), last_time= '13-04-2019' where id = '14';
In which case you'd get something like :-
Thanks for everyone's input, I've worked this out.
The sql query was set up like this:
update users set last_browser= '$user-agent', last_time= '$current_date' where id = '$id_of_user'
edited user-agent with burp suite to be:
Mozilla', last_browser=(select sql from sqlite_master where type='table' limit 0,1), last_time='13-04-2019
Iterated with that found all tables and columns and flags. Rather time consuming but could not find a way to optimise.

Query to search a particular string in single table in oracle 11g

I need a query in oracle 11g that will search all the columns of a table for a particular string and give the result.
I have tried a query given below and it worked for me...
SELECT * FROM account
WHERE ACCOUNT_ID like'%gaurav%'
OR ACCOUNT_NAME like'%gaurav%'
OR PARENT_ACCOUNT like'%gaurav%'
OR WEBSITE LIKE '%gaurav%'
OR TYPE LIKE'%gaurav%'
OR DESCRIPTION LIKE'%gaurav%'
OR ACCOUNT_OWNER LIKE'%gaurav%'
OR PHONE LIKE'%gaurav%'
OR STD_CODE LIKE'%gaurav%'
OR EMPLOYEES LIKE'%gaurav%';
but I need a more simplified solution...as I am having only 10 columns in my table so this solution is okay but what if I have 30-40 columns in my table.
If you have a table with 30-40 columns you should normalize the database: http://www.studytonight.com/dbms/database-normalization.php and you might not need to check all columns (phone for example). Your solution is fine :)
If you need a solution that is generic, repeatable, and simple enough to use, then implement a table function with
input parameters of: "table name", "searched string"
result of: collection of tuple {"rowid", "column name with the match"}
Inside the table function you can implement the functionality you need via means of dynamic SQL.
As for the terms used above ...
collection: http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/composites.htm#LNPLS005
"tuple" = record ... http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/composites.htm#LNPLS005
dynamic SQL: http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/dynamic.htm#LNPLS011
(pipelined) table functions: http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/tuning.htm#LNPLS915

Was it mandatory to put a "distinct" field as the first field in a query?

Just out of curiosity, looks like a distinct field must be placed ahead of any other fields, am I wrong?
See this example in SQLite,
sqlite> select ip, distinct code from parser; # syntax error?
Error: near "distinct": syntax error
sqlite> select distinct code, ip from parser; # works
Why is that? Do I really have a syntax error?
There is no such thing as a "distinct field".
distinct applies to all fields in the query and therefore must appear immediately after select.
In other words, select distinct code, ip is really
select distinct
code,
ip
rather than
select
distinct code,
ip
It selects all distinct pairs of (code, ip). Thus the result set could include repeated values of code (each with a different value of ip).
It is not possible to apply distinct to a single field in the way you're trying to (group by might be a useful alternative, but we need to understand what it is exactly that you're trying to achieve).

Resources