SQL JOIN and desired a view: 2 foreign keys referencing the same table

Tags: ,


I feel I can't solve my task without community help. Unfortunately, my knowledge of SQL is weak. I have 2 tables - user and referral which represents data about senders and referral of senders (...

Tags: sql sqlite

how can I insert new rows from table 2 in table 1 with the corresponding date?

Tags: ,


I have two tables that I want to join using a date field: Table 1: there're multiple records for each date Table 2: there's only 1 record for each date How can I update records in Table 1 with ...

Tags: sql sql-server

SQL syntax alphanumeric characters, SQL Server

Tags: ,


If I pull this ID down from my source system it looks like 9006ABCD. What would the syntax look like if I just want to return 9006 as the ID? Essentially, I don't need the alpha characters.

Tags: sql tsql

Modify SQL to include cumulative sum of all enrollments

Tags: ,


I am able to get members cancelled in a quarter with the below query - SELECT DATEPART(YEAR, Canceldate) [Year], DATEPART(QUARTER, Canceldate) [Quarter], COUNT(1) [id Count] FROM Subscription where ...

Tags: sql sql-server

SQL rotate results from wide to vertical

Tags: ,


I would love some help with the best way to capture some column data and rotate it so I can store the column name and numeric value in a temp table. The results are a single row showing a value for ...

Tags: ms-access sql vba

Multi-Field Search Button (Query) Showing Records With or Without Missing Fields

Tags: , ,


I have a database with only 1 table, this table has 27+ fields and not all of them will contain a value (some will be empty). I have a button ("search alarm") on a navigation form that performs a ...

SQL Server – OPENROWSET Server name error using parameters

Tags: , ,


I'm having trouble with this query...Any idea how to declare variables and make it visible to OPENROWSET query? DECLARE @SERVERNM VARCHAR; SET @SERVERNM = (SELECT(CAST(CONNECTIONPROPERTY('...

Parse a varchar column containing XML like data into row wise

Tags: , ,


i have a column in table which contain data like XML,i would like to get data in rows. My table data as- select printDataColumn from Mytable It returns value-

Tags: postgresql sql

Failed to insert record and return id

Tags: ,


I have a query that returns its id after adding DO $do$ BEGIN IF (SELECT COUNT(*) = 0 FROM COMMENTS WHERE PARENT_ID = ''${this.parent_id}') THEN UPDATE ...

Tags: laravel mysql sql

Mysql query for comparing price one to each other based on type

Tags: , ,


example table name | source_data | price_a | --------------------------------- name A | site_a | 40.00 | name A | site_b | 50.00 | name B | site_a | 30.00 | name B | site_b ...