All Questions
Tagged with subquery sql-server-2008
14 questions
-3
votes
1
answer
297
views
Change Consecutive Row Value [closed]
I am trying to change value of Consecutive AA to first AA as AA1 and second one as AA2, if only one AA then it should be as AA1, its possible to change all AA to AA1 and then search for 2nd ...
-1
votes
1
answer
784
views
MYSQL Error: Incorrect usage of UNION and ORDER BY?
Am trying to randomize my first query but ran into an error "Incorrect usage of UNION and ORDER BY" Kindly find below my queries:
SELECT *
FROM(
SELECT deal_page.id,
...
3
votes
2
answers
204
views
Can subqueries produce different execution plans than CTE's?
I was talking with the bossman, and he prefers subqueries over CTE's. Personally, I loathe subqueries. He mentioned that subqueries can be faster, but I am not convinced. I ran this short test:
...
0
votes
1
answer
1k
views
Query to Find Multiple Start Time and End Time on a Single Day based on Boolean Value
I want to find the multiple Start Time and End time in a single Day based on the Boolean value where data is divided into each half hour interval for a day. So Each day is divided into 24hrs/2 = 48. ...
0
votes
1
answer
105
views
How to get total cost per hotel and transfer per 8 days?
Problem
How to get total cost per hotel and transfer per 8 days ?
Details
8 days = 7 nights
meaning 8 days = 7 days accommodation per hotel
because last day he take flight not stay in hotel .
...
1
vote
0
answers
94
views
How to get total cost of start package table between two periods by sql query?
Problem: how to get total cost of start package table between two periods with a SQL query?
alexaPackage from 28/06/2017 to 05/07/2017 8days cost ?
Details
I need to get total cost in start ...
1
vote
2
answers
398
views
How to use the output of one query in other
I am using following query to get the output as JobId, JobName and Start Execution date
SELECT
ja.job_id,
j.name AS job_name,
ja.start_execution_date,
ja.last_executed_step_id
FROM msdb.dbo....
0
votes
1
answer
211
views
Date comparsion within subquery fails with: "out-of-range value"
I have a an update statement which uses a subquery to filter records. My input table contains dates in a varchar field, and some of them are invalid.
CREATE TABLE [dbo].[input](
[id] int,
[...
4
votes
2
answers
5k
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
...
2
votes
3
answers
4k
views
SQL Subquery , One to Multiple rows
Following query I have written returns the result as expected, example 121350 rows.
SELECT dbo.Articles_in_Consignment.Consignment_id,
dbo.ORDER_D.Orders_boxsize,
dbo.ORDER_D....
0
votes
2
answers
841
views
Tuning query to remove joins for reporting
This is the query I was sent. There is currently no data in the system as I was converting this query from teradata to SQL server.
SELECT user_id FROM user_table
LEFT OUTER JOIN
(
SELECT user_id , ...
0
votes
2
answers
4k
views
Is it possible to join derived tables to actual in Access 2007
Is it possible to join derived tables to actual tables in Access 2007 like in SQL Server 2008? I have an example below:
SELECT *
FROM
--MyOtherTable is a "real" table
MyOtherTable ...
2
votes
2
answers
2k
views
pull records that are inactive
I need help with this query. I have records in customer table
Main table - M
+---------+---------+----------+
| company | Account | Active |
+---------+---------+----------+
| A | A123 | ...
6
votes
3
answers
384
views
Which is the most efficient way to run a particular select query?
If I run the following code:
select PolicyNumber, MAX(decpageid) as decpageid, Risk
from StatRiskDecpages
where PolicyNumber = 'AR-0000301132-04'
group by PolicyNumber, Risk
I get the following ...