Skip to main content

All Questions

Tagged with
-1 votes
2 answers
64 views

SQL Server : create a table where the columns are a row - index mod x

I have a table containing 2 columns - identifier (1, 2, 3...) and the value. It is necessary to make a table, where as columns will be the remnants of division of identifiers by 3. An example: Table1: ...
Zhihar's user avatar
  • 1,378
0 votes
0 answers
22 views

Substring to divide and update a field in the same syntax

sorry in advance if my question is already exists. I'm a sql beginner and have an issue about how can i update a field with 'Select' where one field already exists in the datatable (Table1) and the ...
Joao Marano's user avatar
0 votes
1 answer
963 views

SQL - Multiply values in same table

I have the following code: SELECT ConsumerID, Product, (frequency * Product_Value) as Value_productA (frequency * Product_Value) as Value_productB (frequency * ...
Christian's user avatar
0 votes
1 answer
53 views

SQL - Insert Data from two tables into a third

There is Table1 with Product Information and Table 2 with Client information Table 1 (Product Information) --------------- product | value --------------- Product_A | 5 Product_B | 10 ...
Christian's user avatar
0 votes
2 answers
65 views

Select rows which have a value appear too often (based on dates specified in rows)

I've got a table that describes transactions as shown below (only relevant columns are shown) ID Date Type 1 2017/01/30 1 2 2017/02/01 1 3 2017/02/02 1 ...
Zero's user avatar
  • 1,582
-2 votes
1 answer
73 views

SQL Select same row (amount) times

CAR | AMOUNT --------------------- Ford | 5 --------------------- Peugeot | 7 --------------------- This is my Table, I want to see on my result screen 5 times "Ford" and 7 times "...
kdr_81's user avatar
  • 55
-1 votes
2 answers
975 views

How to check reverse condition with contains in sql server

I am using contains in my select statement to filter street addresses from table as shown below DECLARE @ADDRESS VARCHAR(100) = '0 RUBIN CT APT C2' SET @ADDRESS = '"' + @ADDRESS + '*"' SELECT * ...
Dinesh Reddy Alla's user avatar
1 vote
2 answers
3k views

SQL How to select first match if key has multiple values [duplicate]

Folks, I have the following table... Code UPC 1111 A 1111 B 1111 C 2222 B 2222 A I need to return a table where only one UPC is returned per code (any code), so for table below result should only ...
neualex's user avatar
  • 61
1 vote
2 answers
22 views

How do I remove duplicate records and only take the one with the higest revision number

I would like to only have one record returned for each VariableName, and it needs to be the highest revision number. I have tried GROUP BY and DISTINCT, but nothing seems to work. I have this SQL ...
Drewber81's user avatar
3 votes
3 answers
133 views

Query to return values from table B when newer than record in Table A

I have a table with a member's name, address, etc. and a time stamp of the last time the record was updated. I have a second table that holds updates to the member record, a holding table, until ...
Connie DeCinko's user avatar
-1 votes
2 answers
89 views

Select only distinct columns

i have table T and want select only distinct columns (without correlation between fields) F1 F2 F3 1 A AA 1 B BB 2 B CC 2 C DD 2 C EE 3 C EE desired output F1 F2 ...
Maxrem's user avatar
  • 45
4 votes
2 answers
59 views

Query data from three tables in SQL Server

I have 3 tables called tbl_monday, tbl_tuesday and tbl_wednesday that consist of data as follows: tbl_monday id empid Plan --------------------- 1 6 Mon_27 2 6 Mon_27 3 ...
Rendeep's user avatar
  • 135
0 votes
3 answers
72 views

SQL - replace returned data with other data

I am retrieving data using the SQL syntax below: SELECT TOP 5 EventId, EventTime, DeviceName, Comment, Tenant, TenantName, Individual, InetDb.dbo.Individuals.FirstName, InetDb.dbo....
joebegborg07's user avatar
0 votes
1 answer
54 views

Left join returning bad values

I'm not very good with SQL queries but I attempted to write this one: SELECT DATEPART(YY,Orders.OrderDate) as Year, DATEPART(MM,Orders.OrderDate) as Month, (SUM(case when OrderDetails.ProductCode = '...
henryaaron's user avatar
  • 6,122
1 vote
2 answers
784 views

Select entire row with more than one distinct column

I have a table based on invoice items where I am trying to use SQL to detect at what dates the price or currency for the combination of material/customer has changed. The table contains invoices for ...
ThomasL's user avatar
  • 11

15 30 50 per page
1
2 3 4 5
10