Tagged Questions
-1
votes
2answers
65 views
How to do division from select statements in sql server?
I am trying to create a select statement that can return a table of 1 column.
Basically, I am looping through all the records of NewHire, and then using its id, to select stuff from another table. I ...
-1
votes
3answers
104 views
Add Contents in a Column and make them 0 [closed]
http://sqlfiddle.com/#!3/96f11/3
In the above fiddle, I need the required output in the Fiddle.
ie., The UserID column in Filtered Table and Main table are equal.
I need to get the Amt column data ...
-4
votes
2answers
169 views
Get Hierarchial Data in Self-Referencing Table (Parents , Childs) [closed]
In the following Fiddle,
sqlfiddle
I will pass a sno and I need all the parents of that sno in a table. And all the children of that sno in another table
Please refer to this question. Since ...
-1
votes
2answers
120 views
Select query having count and variable
I have a table like the one below.
I need to form a select query. I'm going to pass a RefID like
SELECT SNo FROM Register WHERE RefID = 1
And beside the SNo in the Statement, I need to have ...
0
votes
2answers
74 views
Need a way to query a table, and JOIN it with the TOP 1 related record from an other table
As a follow up to this question, I'm wondering if there is a better and/or more efficient way to gather the data in question.
As stated, this query does return me 95% of the data I need --
SELECT ...
2
votes
1answer
175 views
SELECT multiple sensor values in one query
Background
I have a couple of devices, each with a couple of sensors. I log these every now and then and stores them in a table described below. When someone requests a web page, I fetch a couple of ...
3
votes
2answers
496 views
Select query according to date
We have a table to store the Events.
Table has got a schema like
EventID INT Primary Key
EventName NVARCHAR(100)
StartDate Datetime
EndDate Datetime
So in the front end we want to show the events ...
3
votes
2answers
278 views
WHERE clause is not filtering on LESS THAN and GREATER THAN or BETWEEN
I am trying to select MTR values that are between the values of 0 and 4. What am I doing wrong?
SELECT
DATEDIFF(M, TheDate, TheOtherDate) AS MTR FROM MyTable
WHERE MyID = 2074163
AND MTR >= 0 ...
2
votes
1answer
862 views
SQL Select WHERE row updated
USE [RF_WORLD]
GO
/****** Object: Trigger [dbo].[lastdeathtrigg] Script Date: 08/20/2012 10:52:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- ...
3
votes
5answers
235 views
Single query to return counts over different IDs in a single record
select count(title_id)as algodata from titles where pub_id =1389
select count(title_id)as binnet from titles where pub_id =0877
select count(title_id)as newmoon from titles where pub_id =0736
...
1
vote
1answer
330 views
How to avoid duplicating information in a series of nested SELECT statements?
I'm working on an SQL query that puts together customer history based on past purchases (the industry is venue ticketing). The report will be LARGE, something like 80-90 columns, with one column per ...
2
votes
2answers
212 views
How can we automatically replace a table with a view for a specific user?
We currently have some reports that query a specific table, but one of our users wants the ordering to be different. I don't want to go through and fix each of the reports, because that's rather a ...
0
votes
3answers
347 views
Can a RDBMS connect to a remote server, execute a select query and copy them into a local table just with SQL commands?
I'm sorry it may sound stupid but I've been wondering about how multiple databases are automated before the virtualization era. Can a DB Adminsitrator make a stored procedure to get data from a remote ...
1
vote
2answers
68 views
Manage select results in sql
We need to manipulate a set of records returned from a select query. This can be done in :
Either by saving the whole record to a table variable and then do the required process.
We can do like this
...
3
votes
2answers
3k views
Can someone explain why select with nolock will query a potion of updated data?
I was reading the answer from here (from stackoverflow, I think should ask in here)
NOLOCK means placing no locks at all.
Your query may returns portions of data as of before UPDATE and
...
4
votes
2answers
1k views
Has SELECT an INSERT clause?
I know the form
Select * into new_table from old_table
statement. Bur recently I found 2 posts here and here which use it like
SELECT * FROM NhlPlayer
INSERT INTO PlayerBackups
I find nothing in ...
6
votes
2answers
2k views
How to use variables inside a select (SQL Server)?
If I want to compute a column and use the result in more than 1 column, how do I do this without making the computing twice?
Example:
SELECT LOWER(SUBSTRING([NAME], 4, 100)) + '@somedomain.com' as ...
2
votes
1answer
112 views
Query table A for any rows that are like any search term in table B
I need some help writing a select statement (I still don't think in sets!). Here's the scenario:
I have table A with column "Name varchar(20)". I have table B with column "SearchTerm varchar(20)". I ...