CREATE TABLE onscreen( id int(2) not null AUTO_INCREMENT, subject varchar(100) not null, content varchar(100) not null, date datetime not null );
Tag: sql
Is there a way to return non existent values when using groupby and union all?
I have a table that I’m trying to return summarized results from for a chart that will have two datasets, one for debit transactions that have happened each month and one for payments that have happened each month. The table I’m querying looks like this: What I’m looking to get back out of m…
Parse out Y-M-D from Y-M-D H-M-S UTC sql bigquery
I need to parse out ‘%Y%m%d’ from the column in BigQuery. My data looks like this: I have tried the following: The error message: No matching signature for function PARSE_DATE for argument types: STRING, TIMESTAMP. Supported signature: PARSE_DATE(STRING, STRING) Desired output: 2000-09-25 Answer W…
SQL – concatenate strings in variable while loop with +=
I can’t concatenate in this example bellow! When I loop I get my 2 correct results. When I concatenate @MaterialCompositionEn += ‘, ‘ it works fine When I try to concatenate @MaterialCompositionEn += same query to get the 2nd row, I have a null! Result: Now when I change to: I am expecting 2…
concatenating large number of tables in sas
let’s assume i have a large list of tables say : all these tables have the same column names and number of columns, i want to stack all these tables one under the other in one dataset i tried to create a macro to do so (because i have multiple other lists that are larger than this but up until
How to fix that procedure in sql
I created procedure which count not null rows in the column, but query throws errors: @tableName is not declared and invalid object name tempTable. I don’t know why code throws that errors, because all variables are declared. Also when I make that program in another way, that code throw Msg 1087, Level …
Partitioning rows into groups by accumulative time interval
I got a search sessions log that looks like this: My task is to partition each row into session groups. Session groups are up to five minutes. For example: Those TOP 3 sessions will form a group session 1 – if we accumulate the minutes between each row, we will get 3 minutes and the 4th would accumulate…
Join tables to display null if right side table doesnt have data
I have a feedback_ques, feedback_ans table as follows: I want to join the tables as follows: This gives me all the fields. I want the query to return null for answers if they arent found in the answers table. For example member_id 20 doesnt have answers, so i would want the table to display null values as bel…
How to multiply all values in one column to make one number?
In SQL Server, I am trying to multiply all values of a calculated column in a table in descending date order, to produce one number. This is so I can calculate a factor that can be applied to a different table / value, i.e. multiplying every value in the “price rate” column to produce a “pri…
How to use nextval() to insert a row containing its own ID in a string
I have a table that contains a column with a string containing its own ID. How can I insert a new line using a single SQL statement? I need something like https://www.db-fiddle.com/f/3NwLNBirN7mHKpDk9NyHSy/1 Answer One option is to select the next serial in a subquery first: You could also use a computed colu…