Category "sql"

How To Run A Github Repository?

I'm a coding newbie, so this may be sort of a dumb question. I was working on an SQL project to learn the language and I wanted to know if there was a way to do

Rails SQL "select in" across several columns: where (code1, code2) in (("A", 1), ("A", 3), ("Q", 9))

I have a business requirement to select records based on two fields in one table: code1 and code2. The selection is complex and hard-coded, with no codeable rhy

Using CASE statement to INSERT values into multiple columns in SQLite

I'm trying to use INSERT statement to add values to a few columns in a new table depending on the value of a column in another table. I'm writing in SQLite. I w

Converting VARCHAR with divide operand to INT

I have a VARCHAR which will return the value something like this '40/4'. Is there a way to convert this VARCHAR to an INT? I tried casting but it is not working

How do I define a variable based on a Case statement or If statement in the middle of SELECT statement?

I am defining the prefix of an address and then trying to remove it from the address. How can I define a variable using an if statement or case statement in the

Parameter name is changed in bin_params using JinjaSql

Imagine this is my query : query = ''' SELECT * FROM table WHERE id = {{myid}}''' params = {'myid':3} j= JinJaSql(param_style='pyformat

How can we use group by keyword on PIVOT table having dynamic column joined with another table or alternative query of Pivot

I have 2 tables named tblDemo and tblSubDemo; tblDemo havve 2 columns _id and _name. tblSubDemo have 3columns, ID,Name, Demo_ID(it is the primary key of tblDemo

node-mssql Transaction insert - Returning the inserted id..?

I'm using node-mssql 3.2.0 and I need to INSERT INTO a table and return the id of the inserted record. I can successfully use sql.Transaction() to insert data,

Give a radio button a hidden text value through selecting an image that is stored with that name in the database PHP/Html

Hello infinitely more knowledgeable stack overflow community. I am trying to accomplish the following: There is this quick form a user fills out and part of tha

How to get ROW_NUMBER() in SQL?

I tried to get the row number using ROW_NUMBER() but it shows the following error: can't format message 13:896 -- message file C:\WINDOWS\firebird.msg not

SQL group by in Subquery

I'm trying to get monthly production using group by after converting the unix column into regular timestamp. Can you please tell how to use group by here in the

Error in MySQL when setting default value for DATE or DATETIME

I'm running MySql Server 5.7.11 and this sentence: updated datetime NOT NULL DEFAULT '0000-00-00 00:00:00' is not working. Giving the error: ERROR 1067 (420

MYSQL - Count Query Taking Time

I am running the following query and it's taking more than 12 sec on my local system. SELECT DISTINCT entity_id_0 FROM (SELECT DISTINCT c0_.enti

postgresql show month start date and end date based on given dates

I need to pull out first date and last date of the month from the given from_date and to_date as input, For Example:- I have my psql output table as the followi

Joining two tables and getting values

I have two config tables. The structure is as below: Table 1: Client_Config id, name, value, type, description Table 2: App_Config name, value, type, descript

Adding a single static column to SQL query results

I have a pretty big query (no pun intended) written out in BigQuery that returns about 5 columns. I simply want to append an extra column to it that is not join

Find a record containing all or a part of a list of id of other table in a many-to-many relation on MySql/Jpa?

In my web application, I have 3 tables: TAB A: Recipes (id, name) TAB B: Recipes_Ingredients(id, fk_recipe,fk_ingredient, quantity) Bridge table TAB C: Ingredie

Match columns by values stored as JSON in another table

I have a table having a JSON datatype column which contains JSON array consisting of IDs for another table. I want to return matching rows from that other table

How to create partitioning dynamically in SSAS tabular model, without using the SSIS package?

I would like to create the dynamic partition in one of my SSAS tabular model. To do so I found one approach with SSIS package which involves the "Analysis Servi

merge two tables with different columns mysql

I want to merge two tables with different columns mysql. For e.g. Table 1 : ------------------------------------------------------------- item_id title sl