Click here to Skip to main content
15,900,110 members
Home / Discussions / Database
   

Database

 
GeneralRe: Indexes Pin
Krish - KP20-Jun-07 2:02
Krish - KP20-Jun-07 2:02 
QuestionStored Procedure Pin
M. J. Jaya Chitra19-Jun-07 18:45
M. J. Jaya Chitra19-Jun-07 18:45 
AnswerRe: Stored Procedure Pin
Xandip19-Jun-07 19:06
Xandip19-Jun-07 19:06 
GeneralRe: Stored Procedure Pin
M. J. Jaya Chitra19-Jun-07 19:12
M. J. Jaya Chitra19-Jun-07 19:12 
GeneralRe: Stored Procedure Pin
Sathesh Sakthivel19-Jun-07 19:21
Sathesh Sakthivel19-Jun-07 19:21 
GeneralRe: Stored Procedure [modified] Pin
Xandip19-Jun-07 19:35
Xandip19-Jun-07 19:35 
QuestionVS05 .NET/ADO how-to param queries, temp tables in visual query designer? Pin
Nosliwekim19-Jun-07 12:30
Nosliwekim19-Jun-07 12:30 
QuestionQuery Help Pin
Hulicat19-Jun-07 10:36
Hulicat19-Jun-07 10:36 
Below is a select statement that will be a stored procedure at some point.
I will only be passing @startdate and @enddate as user defined.
For the purpose of testing I set them to dates

Note:
I am trying to get the data for @totalatstart"total opened at start" and @totalatend "total opened at end" to be specifc to "Client"


declare @startdate datetime
declare @enddate datetime
declare @totalatstart int
declare @totalatend int
DECLARE @difference int

set @startdate ='03/01/2007'
set @enddate = '06/11/2007'

Set @totalatstart =(select count(*) from job_ticket where report_date > @startdate )
Set @totalatend =(select count(*) from job_ticket where report_date < @enddate)
set @difference =(@totalatstart-@totalatend)







select count(*) as 'Opened', @totalatstart 'Total Open at Start', @totalatend 'Total Open at End', @difference 'Total Closed', location_name 'Cient',
AVG(datediff(d,report_date,getdate() )) AS [Average
days open]
from job_ticket j
inner join location l on l.location_id = j.location_id
where (report_date between @startdate and @enddate)

group by l.location_name


Current resluts look like this:

Opened | Total Open at Start | Total opened at End | Total Closed | Client | ||||||| |||| AVG
47 |||||||| 341|||||| |||||||| 48 ||||||||||||||||||| 293 ||||||||| Alexandria, VA||||| 70
59|||||||||| 341|||||||||||| 48 ||||||||||||||| ||| 293 |||||||||| Austin, ||||||||||| 63






Obviously something is wrong with my set statment or my entire approach to this
Any suggestions or help in the right direction would be greatly appreciated.

I have been reading and can not seem to figure this out.

Regards,






Regards,
Hulicat

AnswerRe: Query Help Pin
Pete O'Hanlon20-Jun-07 5:14
mvePete O'Hanlon20-Jun-07 5:14 
QuestionHow to import an SQL database off of my web host's server and onto my desktop? Pin
Nostromo7719-Jun-07 9:10
Nostromo7719-Jun-07 9:10 
AnswerRe: How to import an SQL database off of my web host's server and onto my desktop? Pin
Hulicat19-Jun-07 12:35
Hulicat19-Jun-07 12:35 
QuestionDTS ActiveX Excel Formatting Pin
dario_dee19-Jun-07 7:17
dario_dee19-Jun-07 7:17 
QuestionTOP 1 in select statement with different results. Pin
VK-Cadec19-Jun-07 5:03
VK-Cadec19-Jun-07 5:03 
QuestionRe: TOP 1 in select statement with different results. Pin
andyharman19-Jun-07 6:36
professionalandyharman19-Jun-07 6:36 
AnswerRe: TOP 1 in select statement with different results. Pin
VK-Cadec19-Jun-07 6:53
VK-Cadec19-Jun-07 6:53 
QuestionRe: TOP 1 in select statement with different results. Pin
andyharman19-Jun-07 7:04
professionalandyharman19-Jun-07 7:04 
AnswerRe: TOP 1 in select statement with different results. Pin
VK-Cadec19-Jun-07 7:17
VK-Cadec19-Jun-07 7:17 
GeneralRe: TOP 1 in select statement with different results. Pin
andyharman19-Jun-07 7:30
professionalandyharman19-Jun-07 7:30 
AnswerRe: TOP 1 in select statement with different results. Pin
Mike Dimmick20-Jun-07 1:28
Mike Dimmick20-Jun-07 1:28 
Questionmysql update Pin
WhiteGirl2319-Jun-07 3:20
WhiteGirl2319-Jun-07 3:20 
AnswerRe: mysql update Pin
GoodID19-Jun-07 19:52
GoodID19-Jun-07 19:52 
GeneralRe: mysql update Pin
WhiteGirl2319-Jun-07 21:02
WhiteGirl2319-Jun-07 21:02 
QuestionDetermining Size of Records In SQL Server Table Pin
tjg5_9919-Jun-07 3:07
tjg5_9919-Jun-07 3:07 
AnswerRe: Determining Size of Records In SQL Server Table Pin
andyharman19-Jun-07 6:56
professionalandyharman19-Jun-07 6:56 
GeneralRe: Determining Size of Records In SQL Server Table Pin
tjg5_9919-Jun-07 8:05
tjg5_9919-Jun-07 8:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.