I had two similar fields namely total_weight that is in my phyto table and weight that is in my phyto_species table shown below CreatePhytosTable CreatePhytoSpeciesTable I have been trying to sum weight using array_sum() as total weight and then assign it to ‘total_weight’ => $totalweight] show…
Tag: sql
Add information from two tables to second table
I’m a newbie in query building. I created two tables: product: productid | name | price order: id | productid | quantity | fullprice Can I automatically calculate fullprice (product.price * order….
How to identify entries where a data does not exist in a table with a condition
I would like to pull all data where the Article exist in Table 1 but not in Table 2 when the CnTy is PB00. So if the article exist in Table 2 for other CnTy that is NOT PB00, I still want it on the report. I’ve been using a where CnTY != ‘PB00’ and it just filters out PB00
Select only the records with same values
I am working on a SQL statement that will become a part of a view. What I need is to extract only the records that have the same unique key twice. The query looks like below right now. The result I get from the query above is: I need to modify the SQL statement so that the end result is
Hive QL Declaration
What is the difference between CHAR() and VARCHAR() declarations from HQL?
SQLite book shop: Last students and all books they ordered
forum. I’m trying to run SQL for my local book-shop. The problem is to show last N students and all books they ordered. My try: Is it okay code? Syntax check only shows mistake in a row 8, which I don’t get. Thank you in advance Answer You can join books to orders and filter the results for the la…
How to transform complex form/poll questions to SQL tables?
I need to make system design out of some big form/poll and transform all of that in SQL tables and make db out of it. My problem are questions in which user can choose answer or if the answer is not preset to write it down. So for example question is: Where did you bought your groceries? 1 – walmart
Select max date per year
I have the table as follows: And I’d like to select the max date for every year per user, so the result would be like: Some help? Thank you! Answer Just use aggregation: If you have more columns that you want, then use distinct on:
SQL AVG applied to more than one by group?
I am trying to calculate a column average by group for several groups in the same query. Assume there are 2 columns (a,b), for each I want the average of another column (c) per group of the first column. For example, this would return the a groups and average c value per a group. This gives me two columns. a
How to sort and group data in request?
I have got table. It have some duplicates in purchaseNumber. I need select from this table only newest records for processing. In other words I need to: group elements by purchaseNumber sort them by docPublishDate and select newest. if any of elements in group is have status parsing_status true (suppose it wa…