I have a pretty simple table called Types which contians ID, ParentID and Name. What I need is to get the full hierarchy from an ID, but without including the siblings of the searched ID. I have written the following SQL, which gives me the full hierarchy of the table (with the topmost parent being id ‘246’): So far, so
Split multi-month records into individual months
I have data in a table in this format – where date range is multi-month: I want to create a view/ insert into a new table – the above record broken by month as shown below: Please advise. Answer Just another option using a CROSS APPLY and an ad-hoc tally table Example Returns
MYSQL Specific Order With Conditionals
Okay… I have three columns that I’d like to order based on their conditions. Column 1 (INT) = last_reboot Column 2 (BOOL) = onlinecheck Column 3 (INT) = drive_use I’d like “last_reboot” to be default and ordered descending. If “onlinecheck” = 0, I’d like it to be at the top of my query else ordered by the the “last_reboot” desc.
Unable to join queries
I hope you’re able to help with this, it is creating a lot of unnecessary work for me… I have a lot of users that are assigned a unique session_id each time they start the game. This means they can get multiple session_id ‘s in a single day if they crash and/or just restart the app. I want to be
How to sort products by average rating from another table?
I’m new to databases, so I haven’t wrapped my head around how to use joins, subqueries etc. properly. That’s why I’m very unsure how to go about sorting products by the average of another table. Here’…
How to display Unit as Second Display Item for same display Order?
I work on SQL server 2012 I face Issue : I can’t arrange Features contain Unit as second Item display for same Display Order . for feature family as example ‘Family’ as [Family], ‘FamilyMaxValue’ as …
MySQL – Issue with running the INSERT INTO query
Can someone tell me what did I do wrong on this insert statement: INSERT INTO inventory (typer, prodid, Description, Loc, Price, Total, Available) Values(‘Head’, ‘H001’, ‘KosMom – Blue’, ‘G:Tesd’, ‘…
which query is better to get DATE + 23:59:59
SELECT DATEADD(hh, 23, DATEADD(mi,59 , DATEADD(ss,59 , ‘2019-09-22 00:00:00.000’))) SELECT DATEADD(dd,1, DATEADD(ss, -1 , ‘2019-09-22 00:00:00.000’)) result 2019-09-22 23:59:59.000 2019-09-22 23:59:…
Return result of CASE with Posgres SQL function
I am trying to write a simple SQL function that will be used as a computed field in Hasura.io platform. CREATE OR REPLACE FUNCTION calling_mode(calling_row calling, hasura_session json) RETURNS text …
How to replace Feature Name have Unit word by Unit Only After as Keyword?
I work with SQL Server 2012 and face an issue: I can’t replace Features contain Unit word to be Unit only. So this code returns ‘FamilyUnit’ as [FamilyUnit] while I need it to be ‘FamilyUnit’ as […