I am a high school student and am currently working on an exercise about SQL, which is this query that made me stuck for an hour and still couldn’t solve it. The table schema is as follows: Table The question my teacher gave me was: How any Students have one or more blood donations in 2016? Thanks for a…
MySQL ORDER BY FIELD for months
I have a table called months – this contains all 12 months of the calendar, the IDs correspond to the month number. I will be running a query to retrieve 2 or 3 sequential months from this table, e.g April & May June, July, August December & January However I want to ensure that whenever Decembe…
MySQL: retrieving the last record from each group and combining with the data of another table
There is a purchase table that information regarding the products bought. This will generate one one or more rows in the tStockMP table for each individual product bought. Now, I need to display the table information for each product in stock. Since the purchase table contains the history of the changes, that…
Updating Multiple Columns in sqlite3
I am wanting to update multiple columns in my ‘Class’ Table in sqlite. I do not know how to do this so I approached the same syntax as an ‘INSERT’ query however, I seem to be having the following syntax error: sqlite3.OperationalError: near “VALUES”: syntax error The line I…
Put value on table inside variable?
I need to put a filename that is already listed into a table. I need to put the filename to address to access the file. I already tried this: I expect @filepath will contain something like this D:romliLockAmount_out123456.txt, how I can store the filename in a table to store in a variable? Answer Seeing that …
How to insert the xml nodes with same name and ignore based on the attribute
I have a below xml ` ` I need to insert only the dob nodes which has D and M and Y attributes in table (Table A), if only Y attribute is specified then the entire tag need to be inserted in another table (Table B), how to achieve this is SQL. Thanks for your suggestions Answer Are you looking
Expanding a JSON array embedded in an object in Postgres 11.7
Postgres 11.7. An upgrade to PG 12 (JSONPath, I know) is in planning stages, not sure when we’ll get there. I’m working on passing some data to a PL/PgSQL stored function, and am struggling to unpack an array embedded in an object. I’m dealing with some client libraries that Really Like Obje…
Could not able to retrieve distinct rows from a Column based on the condition of another column in SQL server
I am new to SQL and I have a big table my_table having thousands of rows. The following is a sample: What I want in the output is following: Basically, I want the unique Ids which follow PricingRule as Rule1 from the JsonObject column. I tried the following code: Answer Try the following, here is the demo. Ou…
How to keep SQL data and Elasticsearch in-sync, and which to search from?
I’ve seen two solutions mentioned, and was wondering what most people do. Use logstash Code your application to make writes to Elasticsearch alongside SQL. For example, Another question is how to handle actually searching the entity? Do you ONLY use Elasticsearch? If not, I would assume you fetch from E…
How to implement the like and share feature for a social networking website? [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago. Improve this question I want to understand how the like button is actually implemented in a Web …