Tagged Questions
2
votes
2answers
79 views
Why do I need to use a sub query to filter down a grouped select?
If I do this --
SELECT dv.Name
,MAX(hb.[DateEntered]) as DE
FROM
[Devices] as dv
INNER JOIN
[Heartbeats] as hb ON hb.DeviceID = dv.ID
WHERE DE < '2013-03-04'
GROUP BY dv.Name
...
0
votes
0answers
40 views
Consolidate does not work with my subquery [duplicate]
Possible Duplicate:
SQL Subquery , One to Multiple rows
Following query I have written returns the result as expected, example 121350 rows.
SELECT ...
-3
votes
2answers
266 views
Optimisation sub query SQL Server
I would like to optimise the query below because it's actually taking 40% of the time in the real one. I HAVE to get the first line in the table 2 for each line in the table 1. The relationship is 1 ...
0
votes
2answers
119 views
Are these two queries technically equal to each other?
Ran it in my query browser. I was am getting same results for both. But still need a confirmation.
SELECT
cs.RSCode
, CustomerName
, em.EmailId
FROM
Customer_STN cs
JOIN ...
1
vote
1answer
124 views
Querying multiple tables
I am working on a query from our ticketing system, and I am having problems figuring out the best way to join these tables together.
I have the following tables/fields:
SR_service: stores ticket ...
7
votes
2answers
1k views
Subqueries' aliases same as main queries' aliases
I have an SQL query whose aliases are the same as some of its subquery's aliases.
For example:
select *
from ROOM r
where ...
(
select *
from ROAD r
...
1
vote
0answers
278 views
time interval period in sql [closed]
How to display the time period of the most widely in use in ms sql server
I have purchase data, such as:
hours the number of purchases
10:00 2
12:00 4
13:00 5
14:00 1
...