I have the following SQL: SELECT members.id, FLOOR(DATEDIFF(‘2019-10-25’, crew_cv.dob) / 365.25) as age FROM members JOIN crew_cv ON members.id=crew_cv.user_id WHERE members.active=1 AND age>20 …
Tag: sql
How can I join these rows together with commas as a column in my select?
I have the following query: SELECT STRING_AGG(SELECT department FROM additionaldepartments WHERE employee = e.EMPID, ‘,’) AS additional_departments, r.actionId, e.EMPID AS `id`, …
INNER JOIN is not working, i do not get errors
$result = mysqli_query($conn,”SELECT * FROM table1 INNER JOIN `table2` ON `table1`.`id`=`table2`.`id`;”); while ($row = mysqli_fetch_array($result) ){ echo ‘name ‘.$row[“name”].'<…
Is it possible to use OR in a table link rather than AND
I have created a WorkFlowForm to allow logistical personal to combine multiple picknotes on one set of despatch paperwork. The WFF has all the header information and should pull through all the …
How to add if statement in knex.select()?
I have code like this const attr = req.query.attr knex.select(knex.raw(‘foo_name as name’)) what I want is somehow select that column if it meets condition of attr and if does not then do select …
Selecting columns from tables based on max value of another column
I have two tables and I want column input from first_table and column output from second_table based on the latest finished time first_table: second_table result_table I am trying to use this query: Answer You can use a correlated subquery in the on clause of the join: For performance here, you want an index …
Using Classic ASP – SQL – JSON
I’m trying to serialize a SQL query in Classic ASP to a json object and I have found some great code that helps me achieve that but where my issue comes in is I then need to manipulate the output that is returned by the QueryToJSON(cmd, arParams).Flush I need to take the value and add some string / text…
Getting Error While Setting The data to Sql Db, Saying Cannot set the Value of Created at with Null
I am Creating a table in SSMS with the Columns required for the Table and also with the Entitydata mandatory fields Like Id, CreatedAt, UpdatedAt, Version, Deleted. And while setting the data through …
how to convert to_timestamp(’12-10-18 12:00:16.565736000 PM’,’DD-MM-RR HH12:MI:SSXFF AM’) into MySQL
I have one insert query in oracle — Insert into sample (name,time) values (‘RJ-valley’,to_timestamp(’12-10-18 12:00:16.565736000 PM’,’DD-MM-RR HH12:MI:SSXFF AM’)); select time from sample; output …
pick the first result for each parameter
I have a table with account_number, account_code and code_date I am trying to get the latest code for each account, but the group by is giving me multiple observation for each account, thus I can’t …