How to join 3 collections into the same gallery? - powerapps-collection

How do I join 3 collections into the same gallery in PowerApps ?

This is not enough information to answer the question.
But guessing on what you want:
Lets say you have data source JOB_III and JOB_IV where JOB_III has a column named JobName, if JOB_IV has a column named JobName as well but some other info, you can use:
First(
Filter(
JOB_IV,
JobName = ThisItem.JobName
)
).JobSalary
This will get you the salary from the JOB_IV table nested in the gallery of JOB_III
G'Luck!

Related

How to count favorites and all data of an other table with JOIN

I try to select the favorites for each wines in my database and all data from wines but with the group by obligation, I can't have data for wines which don't have a favorite_score, so do you know how to do please.
SELECT SUM(wine_id) as favorite_score, wines.*
FROM wines JOIN
favorites
ON favorites.wine_id = wines.id
WHERE wine_color in ('White') AND
available = 1
GROUP BY wines.id
ORDER BY wines.id
This is my SQL request for instance and now this my DB diagram :
enter image description here
So, I want all data for each wine and favorite_score too for each one or 0 if there is no data corresponds on wines.id = favorites.wine_id
Sorry for my English, I'm French
I wouldn't do a sum, because that will sum all the wine_ids and not the number of wine_ids in the table favorites.
for example, you have wine_id = {50, 100,123} and a SUM(wine_id) would be 273, but I assume that what you want is 3 instead. So based on that, the query I would do is as follows
select count(f.wine_id) as favorite_score, w.*
from wines as w
join favorites as f
on w.id = f.wine_id
WHERE w.wine_color in ('White') AND
w.available = 1
group by w.id, w.price, w.certification_label, w.label_name, w.vintage, w.oenological_comment,
w.area, w.city, w.variety_of_wine, w.age_of_vineyard, w.soil, w.prunning, w.harvest,
w.vinification, w.quantity, w.barrel_fermentation, w.image_path, w.available, w.wine_color,
w.award, w.award_path, w.extra_comment
order by w.id
Let me know if you have any questions. Also, don't forget that for the count to work you need to add all the other fields in the group by, so I would advice you to only take the necessary fields.

SQL - Getting a column from another table to join this query

I've got the code below which displays the location_id and total number of antisocial crimes but I would like to get the location_name from a different table called location_dim be output as well. I tried to find a way to UNION it but couldn't get it to work. Any ideas?
SELECT fk5_location_id , COUNT(fk3_crime_id) as TOTAL_ANTISOCIAL_CRIMES
from CRIME_FACT
WHERE fk1_time_id = 3 AND fk3_crime_id = 1
GROUP BY fk5_location_id;
You want to use join to lookup the location name. The query would probably look like this:
SELECT ld.location_name, COUNT(cf.fk3_crime_id) as TOTAL_ANTISOCIAL_CRIMES
from CRIME_FACT cf join
LOCATION_DIM ld
on cf.fk5_location_id = ld.location_id
WHERE cf.fk1_time_id = 3 AND cf.fk3_crime_id = 1
GROUP BY ld.location_name;
You need to put in the right column names for ld.location_name and ld.location_id.
you need to find a relationship between the two tables to link a location to crime. that way you could use a "join" and select the fields from each table you are interested in.
I suggest taking a step back and reading up on the fundamentals of relational databases. There are many good books out there which is the perfect place to start.

SQL Query: How to list joined values on the same row

I've got a table of job listings and a related table which contains the job listing ids and each of the field values in a 'field title' -> 'field value' format.
So to get my listing of jobs, I've JOINED the tables in my SQL Query, but am getting the results on multiple lines because of that. Let me illustrate.
Query is something like:
SELECT list.id, list.activation_date, list_field.value
FROM listings AS list
INNER JOIN listings_fields AS list_field ON list.id = list_field.id
WHERE list.activation_date > SOME VALUE
AND list_field.field_id IN ('Title', 'Category')
ORDER BY list.activation_date DESC, list_field.field_id DESC
The result looks like this:
51325 2012-07-31 Job Title 1
51325 2012-07-31 Category 1, Category 2
51324 2012-07-31 Job Title 2
51324 2012-07-31 Category 3
51323 2012-07-31 Job Title 3
51323 2012-07-31 Category 1, Category 3
I've got all the data I need, it's ordered consistently with title first and category second, but I can't think of how to get the result all in one row. This must be a common problem with a well-known trick, and I'm sorry I don't know it yet.
Still learning. If anyone can help, I'd really appreciate it. :-)
Something like
SELECT list.id, list.activation_date, list_fieldJ.value,list_fieldC.value
FROM listings AS list
INNER JOIN listings_fields AS list_fieldJ ON list.id = list_fieldJ.id
and List_fieldj = 'Title'
INNER JOIN listings_fields AS list_fieldC ON list.id = list_fieldC.id
and List_fieldC = 'Category'
WHERE list.activation_date > SOME VALUE
ORDER BY list.activation_date DESC
Basically join once for title and then again for Category. Needless to say it's a pain if you have more than few value types to get out. And the above assumes that a job will always have title and category. Optional ones you'd need an outer join on.

Oracle SQL get column value associated with max(count())

I have the following query. What results is two coloums, oakid and max(count(rating)). What I want is to have two columns, but instead of actually having the max(count(rating)), I want the rating associated with the max(count(rating)). How can I modify my query to give me this?
select oakid,
(select max(count(rating))
from climbs, routes
where climbs.routename = routes.name
and climbs.climberid = oakid group by routes.rating)
as skill
from climbers;
For example, if I have ratings "hard, hard, easy, easy, easy, medium", the max(count(rating)) will show "3", since there are 3 "easy" ratings, but I want it to show "easy", not "3".
It sounds as though you want the statistical mode (most frequently occurring) rating for each oakid or climberid. Oracle has a handy function to do this for us called STATS_MODE:
SELECT c.climberid AS oakid, STATS_MODE(r.rating) AS skill
FROM climbs c
INNER JOIN routes r ON (c.routename = r.name)
GROUP BY c.climberid;
try the following:
select oakid,
(select rating
from climbs, routes
where climbs.routename = routes.name
and climbs.climberid = oakid
group by routes.rating
having max(count(rating)) = count(rating))
as skill
from climbers

NHibernate Return Values

I am currently working on a project using NHiberate as the DAL with .NET 2.0 and NHibernate 2.2.
Today I came to a point where I had to join a bunch of entities/collections to get what I want. That is fine.
What got me was that I do not want the query to return a list of objects of a certain entity type but rather the result would include various properties from different entities.
The following query is not what I am doing but it is kind of query that I am talking about here.
select order.id, sum(price.amount), count(item)
from Order as order
join order.lineItems as item
join item.product as product,
Catalog as catalog
join catalog.prices as price
where order.paid = false
and order.customer = :customer
and price.product = product
and catalog.effectiveDate < sysdate
and catalog.effectiveDate >= all (
select cat.effectiveDate
from Catalog as cat
where cat.effectiveDate < sysdate
)
group by order
having sum(price.amount) > :minAmount
order by sum(price.amount) desc
My question is, in this case what type result is supposed to be returned? It is certainly not of type Order, neither is of type LineItems.
Thanks for your help!
John
you can always use List of object[] for returning data and it will work fine.
This is called a projection, and it happens any time you specify an explicit select clause that contains rows from various tables (or even aggregate / summary data from a single table).
Using LINQ you can create anonymous objects to store these rows of data, like this:
var crunchies = (from foo in bar
where foo.baz == quux
select new { foo.corge, foo.grault }).ToList();
Then you can do crunchies[0].corge for example to pull out the rows & columns.
If you are using NHibernate.Linq this will "just work".
If you're using HQL or Criteria API, then what Fahad mentioned will work. You'll get a List<object[]> as a result, and the index of the array references the order of the columns that you returned in your select clause.