How can I do a UNION operation with DexieJS? - dexie

I have a indexedDB with firstName and lastName as columns.
Here is some sample data:
firstName lastName
__________________
John Doe
Mary Doe
Jacob Adams
Doe Mary
When I search for Doe, the query should return the first two entries and the last. If I search for Jacob, it should return the second last.
I followed examples from this Dexie sample, but I can't do a single search on two fields at the same time. If not, is there a way to run two questions and UNION the results to a single one?

Sounds like this:
table.where('firstName').equals('Doe').or('lastName').equals('Doe')

Related

Neo4J : How to Order results by attributes value

How do I order my results using Node properties value using Cypher Queries?
For Example :
I have the below results :
Person
City
Kasper
London
Sean
Chicago
Tom
London
Kate
New York
John
London
Sarah
Chicago
I want to sort the above result on basis of "London" i.e people from London should be on top. The sorted results can look something like this :
Person
City
Kasper
London
John
London
Tom
London
Kate
New York
Sean
Chicago
Sarah
Chicago
I know Order By clause can be used to sort in ascending or descending order but can we use it to sort on the basis of Value? If not, please suggest some other way to do it. Thanks in advance.
you can sort by property value . imagine (p:Person) and (c:City) nodes
RETURN p.name AS Person, c.name AS City
ORDER BY City
another example
WITH p,c
ORDER BY p.birthdate
RETURN p.name AS Person, c.name AS City
in case you want to order by age.
if your cities have to be in an order based on a specific property, add e.g. index to the city node , and do something like:
WITH p,c
ORDER BY c.index
RETURN p.name AS Person, c.name AS City

Google sheets function : Filter records by multiple condition

I have 2 sheets : Sheet1 has large number of records with columns Firstname, Lastname and Company. Another Sheet2 has same columns but small set of records. I want only those records from sheet1 which have a matching firstname and lastname in sheet2 but company is different. How can I achieve this with help of a formula? (it has to be scale-able).
E.g.
Sheet1
Firstname Lastname Company
John Doe ABC
Jon Smith XXX
Dan S. XXX
John Davies XXX
Sheet2
Firstname Lastname Company
John Davies ABC
Jon Smith XXX
Expected output :
Firstname Lastname Company
John Davies XXX
Try below formula:
=SORT(IFERROR(ARRAYFORMULA(SPLIT(ARRAYFORMULA(VLOOKUP(ARRAYFORMULA(E2:E&" "&F2:F&" "&C2:C),ARRAYFORMULA(A2:A&" "&B2:B&" "&C2:C),1,0))," ")),""),1,false)

sql dev query moving multiple rows to many columns

I am very new to sql dev and have a query with results below...
TeacherID TFirstName TLastName StudentID SFirstName SLastName
11113 Doe John 12345 Jane1 Doe1
11113 Doe John 12346 Jane2 Doe2
11113 Doe John 12347 Jane3 Doe3
I get many rows of one teacher with all their students in rows.
I want one teacher with all the students in columns.
Teacherid tfirstname tlastname studentid sfirstname slastname studentid sfirstname slastname studentid sfirstname slastname
11113 Doe John 12345 Jane1 Doe1 12346 Jane2 Doe2 12347 Jane3 Doe3
and so on for the 20 students in this class.
Is this possible? Like I said I am new to sql dev.

Sqlite query to determine gender by first name

I have 2 sqlite3 tables :
FND is a Table of names and their likely gender i.e.:
nm,gndr <-column names
Aliyah,F
Moses,M
Peter,M
Members is second table i.e.
Fname,Lname <-column names
DAVID X, BAKER
MARY MIA,MCGEE
TINA HEATHER,JOHNSON
JIM PETER TOM, SANTINO
The members table has first and middle names in the fname column.
I am trying to write a query to list the Members table fnames column, with a generated column indicating gender based on the first word in the fname column.
I tried this but it didn't work:
select m.fname,(select gndr from FND where upper(nm) like m.fname||'%')as gender
from Members m
can anyone correct my sql statement?
... upper(nm) like m.fname||'%'
Let's look at some example values:
nm: 'David'
fname: 'DAVID X'
SQL: 'DAVID' LIKE 'DAVID X%'
This obviously does not match.
You have to reverse the LIKE operands:
m.fname LIKE nm||'%'

Where two or more values match condition?

I have been asked this question;
You list county names and the surnames of the representatives if the representatives in the counties have the same surname.
and I have the following tables;
***REPRESENTATIVE***
REPI SURNAME FIRSTNAME COUNTY CONS
---- ---------- ---------- ---------- ----
R100 Gorege Larry kent CON1
R101 shneebly john kent CON2
R102 shneebly steve kent CON3
I cant seem to figure out the correct way to ask Orical to display a surname that exists more then twice and the surnames are in the same country.
I know how to ask WHERE something = something, but that's doesn't ask what I want to know.
It sounds like you want to use the HAVING clause after doing a GROUP BY
SELECT surname, county, count(*)
FROM you_table
GROUP BY surname, county
HAVING count(*) > 1;
If you really mean "more than twice" as you wrote, none of the data you'd want HAVING count(*) > 2 but then none of your sample data would be returned.
In words, this SQL statement says
Group the data into buckets by surname and county. Each distinct combination of surname and county is a separate bucket.
Count the number of rows in each bucket
Return those buckets where there are at least two rows

Resources