I’m trying to get one row for each hour of the day, which I intent to left join certain data to. I need selected the 00:01:00 and 23:59:00 interval hour for each day. I have tried this solution but I can’t selected 00:01:00 and 23:59:00 interval hour but only 00:00:00 and 23:00:00 interval hour. H…
Tag: sql
sql – Add 0 after a numeric value
I have columns in my sql table. I am wondering how can I add zero after numeric values in my columns. So for example: I have values e.g 9, 2, 7, 10. I want to add a zero after these numbers. I want them to be 90, 20, 70, 100. There are some values in the columns that already have
How to use Distinct OR Group by with Inner Join?
have a problem with sql query, simple one but though I’m sitting on it 3d day and cant figure out what is wrong, please help. Table 1: Table 2 Result Desired result – in my reslt I want to display each portfolio ID ONLY ONCE. sql query: Any ideas / solutions are welcomed. Thank you Answer Use row_…
How to get the sum of a subquery that returns sums?
I would like to get the sum of the “sums” in the following case. How can I do that? The following picture represents the table I receive after performing the code below. I’d like to receive only 2 …
Building an Employee Date Matrix
I have a list of employees, along with list of cities they’ve worked in. I need to build a matrix (in SQL Server) of start/end dates by city to determine where they were at any given period in time. The “end date” would be exactly the date before they appeared at a new location. I’ve i…
What’s the best way to handle an ‘very large’ inventory with SQL? [closed]
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago. Improve this question I am looking into building an online card game like that of Hearthsto…
How to get a COUNT() value when GROUP BY has no row?
RDMS : MariaDB 10.1.23 MCRE : SQLFiddle: http://sqlfiddle.com/#!9/f32a01/1 Consider the following query : Without the GROUP BY clause, I know that COUNT() will return 0 if no row match the query. I also know that, if my GROUP BY “fails” (If i have no row to group by, in my example, if no row satis…
Check the number of digits or their range
I tried to create a table for save Tradeshows and I need to save Year and Month into different columns. I have a problem with my back-end and front-end developers for check data. I need to check years is 4 number and month between 1-12. Speed is important to me. Answer Just use check constraints: Or, you coul…
SQL table join on itself but allow “0” value
Okay so i have a simple table “category” on this table categories and subcategories are saved. categories have “parent_id=0”, and subcategories have a “parent_id” that equals the row_id of the …
want to use sql count online people with begintime and endtime
I want to use sql count online people with begintime and endtime on presto。 my data like : userid begintime endtime 023150000030040 2020-03-05 12:50:46 2020-03-05 12:50:49 023150004186637 2020-03-…