Work Time Selection

May 29, 2008

Hi,

I'm writing a query to select rows that are included in work time :


AND ((SUBSTRING(CONVERT(char(30), Dateid, 120),12,8) >= @WorkTimeIni and SUBSTRING(CONVERT(char(30), Dateid, 120),12,8) <= @WorkTimeEndAM)

OR (SUBSTRING(CONVERT(char(30), Dateid, 120),12,8) >= @WorkTimeIniPM and SUBSTRING(CONVERT(char(30), Dateid, 120),12,8) <= @WorkTimeEnd))

is there another way to do this, i mean, with a more simple sintax..?



entire query :

(SELECT COUNT(tblindex.recordNum)

FROM SRVCCC.SDXARCHIVER.dbo.tblIndex as tblindex

LEFT JOIN SRVCCC.SDXARCHIVER.dbo.tblCallDirectionCodes as CalldirCode

ON tblIndex.cdir = CalldirCode.CallDirectionCode

WHERE dateid >= @CalcPeriodStart and dateid < @CalcPeriodEnd

AND ((SUBSTRING(CONVERT(char(30), Dateid, 120),12,8) >= @WorkTimeIni and SUBSTRING(CONVERT(char(30), Dateid, 120),12,8) <= @WorkTimeEndAM)

OR (SUBSTRING(CONVERT(char(30), Dateid, 120),12,8) >= @WorkTimeIniPM and SUBSTRING(CONVERT(char(30), Dateid, 120),12,8) <= @WorkTimeEnd))

AND ndbo=@Subset AND ( (cdir ='I') or (cdir='C' and ccid in('7','27')) or (cdir='N' and ccid='7')) )

View 6 Replies


ADVERTISEMENT

Select Statement With Run Time Field Selection

Jan 3, 2008



I have this SELECT statement.


SELECT [issueID], [name] FROM [MyIssue]


What I wanted to do is in addition to the above statement, I want to add two run time fields like this:


99 [issueID],'All Issues' [name]

So let's say the above select statements generates this list:

Summer 2007 Issue
Winter 2007 Issue

The two addition fields will make the result list like this:

01 Summer 2007 Issue
02 Winter 2007 Issue
99 All Issues


How do I accomplish this? Any help is much appreciated.

View 5 Replies View Related

Filtering Out 1 Time Dimension Based On The Selection In Another Time Dimension

May 19, 2008

Hi!

Need some help building a query that does the following :

I have 2 Time Dimensions ; Time (Transdate) and ClosedDate (ClosedDate)

In my report/query, if [Time].CurrentMember = [Time].[YMD].[YMD].[2006].[200610].[20061031] I want to FILTER out all ClosedDate < [ClosedDate].[YMD].[YMD].[2006].[200610].[20061031]

Both Time Dimensions are Year -> Month -> Day and have the same Members.

I have every option available, using calculated Members and/or Measures to do this.

The report I'm creating is Aging of Receivables : Balance / 30 days / 60 days / etc.. But for the Aging, I need to filter like explained above.

Appreciate all help!

Regards,
Stian Bakke

View 3 Replies View Related

Data Selection Not Happening For A Date Because Of Time Format

Jul 14, 2006

hello all,

i am making a query which select the data again a particuler date.

I insert values in the table for with current date(Today's date) and the records is inserted with the date format(2006-07-14 16:12:09),now when i run the query after 2 or 3 minutes to select the records inserted today, my query returns no results.

I think it is because of the the time (14:16 in this case) that after 2 minutes, the query looks for the records inserted at (2006-07-14 18:12 or 2006-07-14 19:12) and does not get the result.

Is there a method to not consider the time(14:16) when running the query but the query fetches the records including the records inserted at this time(14:16) no matter at what time I run the query today?

Please anyone help me!

Thanks in advance!

View 4 Replies View Related

Sync Will Work Only 1 Time.

Jan 29, 2007

I am really stuck on this, if anyone has some insight into this problem
any help would appreciated...
I'll try to explain what is happening the best I can:


We have a server running Windows Advanced Server 2000 (SP4) w/ SQL
server 2000 (SP3) (from now on Server A). I have a publication on this
machine with dynamic filters (Changing the HOST_NAME()). The
publication is sending the snapshots to another machine (desktop
machine). The Mobile agent is in the same machine as the snapshots.


The mobile application is syncing fine when hitting Server A. The sync
is done Asynchronously.


Then we have Server B. Running Windows Server 2003 (SP1) w/ SQL 2000
(SP4), same publication w/ dynamic filter however the snapshots and the
mobile agent are in this server.


The mobile application will sync the 1st time but any subsequent syncs
will not work. I check on the Replication monitor and it tells me that
the Merge was a success but the mobile application will not execute the
download table callback, it will execute the Sync callback 5 times and
not proceed in executing the download table callback.


If I change the configuration on the mobile app to point to Server A
the sync will work just fine but, if I change it back to Server B the
sync will work once then it will stop working.


Anyone have some suggestions for troubleshooting?

View 6 Replies View Related

How To Work With Time In Format 'hhh:mm:ss' (more Than 24 Hours)

Sep 19, 2007

Hello,I need to create a column that will store hours bigger than 24. Forexample '25:00:00', '129:23:12', etc).That column will be used too, for perform calculations betweendatetime intervals: 'time'.In MySQL there is a datatype that perfect fits that necessity.Does anyone know what is the corresponding datatype in SQL Server?Thanks a lot!

View 4 Replies View Related

How Can I Estimate Time, Which Query Needs To Complete Work?

Jan 28, 2008

As in title. Is there any tool? I'm asking beceuse, I have some big bases, and processing may take a lot of time (at least few hours), and I'll be glad if it's possibility to know estimate time before query runs. I'm using MsSql 2005 Developer edition.

View 14 Replies View Related

Calling The Same Store Procedure Repeatly, But Only Work In The First Time

Apr 18, 2006

I had try calling a function, that call a store procedure, repeatly using a for loop, but I notice it will only get the expected part_id in the first time, and return an empty string sub-sequentially without throwing an exception. So I had try using a sql query instead, but the same thing happen. Below is my function, can you point out to me what's wrong?
My original version that calls a store procedure
Public Shared Function getPartId(ByVal part_supplierserialnumber As String) As String
Dim mySqlCommand As New SqlCommand
Dim mySqlConnection As SqlConnection = New SqlConnection(GetERATSConnectionString())
Dim myPart_id As String
mySqlCommand.CommandType = CommandType.StoredProcedure
mySqlCommand.CommandText = "getPartId"
mySqlCommand.Connection = mySqlConnection
mySqlCommand.Parameters.Add(New SqlParameter("@part_supplierserialnumber", part_supplierserialnumber))
Try
mySqlConnection.Open()
myPart_id = mySqlCommand.ExecuteScalar()
Catch ex As Exception
myPart_id = ""
Finally
mySqlConnection.Close()
mySqlConnection.Dispose()
End Try
Return myPart_id
End Function
My Store procedure
create procedure getPartId@part_supplierserialnumber as nvarchar(50)as
select top 1 part_id from tblPtSingapore where part_supplierserialnumber = @part_supplierserialnumber order by part_datecreated desc
 
GO
The new version I tried which happen the same thing
Public Shared Function getPartId(ByVal part_supplierserialnumber As String) As String
Dim myPart_id As String
Dim strSql As String = "select top 1 part_id from tblPtSingapore where part_supplierserialnumber = '" & part_supplierserialnumber & "' order by part_datecreated desc"
Dim mySqlConnection As SqlConnection = New SqlConnection(GetERATSConnectionString())
Dim mySqlCommand As New SqlCommand(strSql, mySqlConnection)
Try
mySqlConnection.Open()
myPart_id = mySqlCommand.ExecuteScalar()
Catch ex As Exception
myPart_id = ""
Finally
mySqlConnection.Close()
mySqlConnection.Dispose()
End Try
Return myPart_id
End Function

View 2 Replies View Related

Prob With SQL Script That Work With Date/Time Abd Boolean

Jul 23, 2005

I convert my DB from Access to SQL Server ,When i try to run my script (in ASP) it's not store the data atDate/Time field!!!And i have troble with insert the value TRUE in Sql Server (it's workwith access)I want to know if i need to change my scripts(in ASP) or the type offields?Please, HelpBest regards.

View 2 Replies View Related

Enabling And Disabling Tasks At Run Time Using Expressions Does Not Work Properly

Jul 28, 2007

Hi Friends
"I wonder why the boolean values Set to "Disable Property" using expressions does not work as expected (though Precedence constraints work fine). I find no way to disable individual task. "

I have a boolen variable V, (False) enabled by default at design time for a task T, I disable T based on a condition (if A ! = 'a') during runtime.

Now first time when I run the Package, Task gets disabled (works fine on the condition given). However T gets permanently disabled even after we stop debug mode, which is not the expected behavior. Further on when you run, it wont work at all.

Is it true that a task disabled at design time cannot be enabled during runtime via expressions ?

If things are working fine in your case, pls let me know what settings are required.

Thanks
Subhash Subramanyam

View 5 Replies View Related

SQL Server 2012 :: Date / Time Calculations For Work-plan Times?

May 31, 2015

I have a table that stores working hrs, such as

RecID,StaffID,StartDate,EndDate
17,969,2015-05-18 00:00:00.000,2015-05-18 06:00:00.000
18,969,2015-05-18 18:00:00.000,2015-05-19 06:00:00.000
19,969,2015-05-19 18:00:00.000,2015-05-20 06:00:00.000
20,969,2015-05-20 18:00:00.000,2015-05-21 06:00:00.000
21,969,2015-05-21 18:00:00.000,2015-05-22 06:00:00.000
22,969,2015-05-22 18:00:00.000,2015-05-23 06:00:00.000
23,969,2015-05-23 14:00:00.000,2015-05-24 08:00:00.000
24,969,2015-05-24 22:00:00.000,2015-05-25 00:00:00.000

So working times can go over midnight, there can be more than one working period in a day etc.

For this staff member the summary of the weeks work will be

18/05/2015 - 12 hrs
19/05/2015 - 12 hrs
20/05/2015 - 12 hrs
21/05/2015 - 12 hrs
22/05/2015 - 12 hrs
23/05/2015 - 16 hrs
24/05/2015 - 10 hrs

Now for the complicated part, a person can take absence(sick,holiday,other) for any part of a day or whole day(s). For these absence periods only the worked time on that day needs to be negated off, not the whole period of time.

So for example

If this person

had a days holiday on the 22nd, shown in the HOLIDAY table as

StaffID,DateFrom, DateTo
969, 22/05/2015 00:00:00.000,22/05/2015 23:59:59.000

A Leave of Absence on the 20th, shown in the LEAVE table as

StaffID,DateFrom, DateTo
969,20/05/2015 12:00:00.000,20/05/2015 16:00:00.000

And was off sick on the morning of the 19th, shown in the SICKNESS Table as

StaffID,DateFrom, DateTo
969, 19/05/2015 00:00:00.000,19/05/2015 11:59:59.000

Now the Summary table should now show

18/05/2015 - 12 hrs
19/05/2015 - 6 hrs
20/05/2015 - 12 hrs
21/05/2015 - 12 hrs
22/05/2015 - 0 hrs
23/05/2015 - 16 hrs
24/05/2015 - 10 hrs

The 'Leave of Absence' on the 20th had no effect on the total for the day as it was between planned work times. how to do this within T-SQL, as simple as possible as I've got to had this code over to other staff members to maintain, who have not had much SQL experience yet?

I've tried doing it as a temp table, with dual insert/select commands, splitting the times over midnight, which partially worked but missed some of the combinations.

View 1 Replies View Related

Can’t Make Vs2008pro, Sql2005dev, Sqlexpress All Work Together Via F5run And Vista Localhost At Same Time??

May 16, 2008

Clean vista install,
Clean full office 2007plus install
Clean visual studio 2008pro install
Many failed sql 2005dev installed, did SKUUPGRADE-1
Now have office2007 Smallbiz, VS2008pro, SqlExpress and sql 2005dev installed.
Note outlook 2007 error on first run after sql2005dev.
Seams to have broken and created a new sql connection, don€™t think its the original.
but that€™s not the current issue !
web admin page error, could not connect to db
I did regsql.exe from the net dir and the web admin work and the db is created for roles and such in vs 2008 via web admin page and mssql.
Managed to create db in apps data folder and modify connection in server explorer.
Added table to aspx page from apps folder and it runs via f5, but errors under localhost.
€œCannot open user default database. Login failed.€?
€œLogin failed for user 'NT AUTHORITYNETWORK SERVICE'€?
Have seen some reference to iis permissions, but not sure what to change?
Is it a file level permission, a virtual permission
Works in vs2008 using f5 run!
http://localhost:50115/vs2008/
Can work with apps folder db file in vs 2008 server explorer
Had to modify db connection back to sqlexpress in server explorer
Can work with db in sql management studio, have three local instances;
Pc
Pcsqlexpress
Pcsmallbiz
Can display db data in aspx page via f5 , but not localhost unless vs2008 is not running!!!
Have not been able to make vs2008, Sql2005dev, sqlexpress all work together using iis in vista via localhost and vs2008 f5 at same time??
Can€™t do anything with db in solutions explorer, but can work in server explorer if I modify connection back to sqlexpress
Can€™t display data aspx page via localhost
http://localhost/vs2008/
Cannot open user default database. Login failed.
Login failed for user 'NT AUTHORITYNETWORK SERVICE'
Localhost works in iis via virtual directory if I remove db grid in page or vs is not running
Could someone test and tell how to use all of these together?
What is going to happen if I get it to work local and then try to upload to shared host?
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Server=wabpc;Database=VS2008test;Integrated Security=true" providerName="System.Data.SqlClient" />
<add connectionString="Server=SQLEXPRESS;Database=Database.mdf;Integrated Security=true" name="sqlexpress" />

</connectionStrings>
If I close vs2008 and the management studio, localhost works and displays the db info!!
Open vs2008, modify connection back to sqlexpress and the aspx page breaks via localhost
Close vs2008 and local host works
Open vs2008 and get a error 25 in server explorer connection string invalid, but f5 works after the offline clears.
I change db connection back to sqlexpress to work with db in server explorer!
That breaks localhost, but f5 works

Any ideas?
Need more Tylenol

View 9 Replies View Related

How To Convert UTC Time (retrieved From SQL) To Local Time In Reporting Services Based On Time Zone

Aug 7, 2007



Hi all,

I have created a report in SSRS 2005 which is being viewed by users from different Time Zones.

I have a dataset which has a field of type datetime (UTC). Now I would like to display this Date according to the User Time Zone.

For example if the date is August 07, 2007 10:00 AM UTC,

then I would like to display it as August 07, 2007 03:30 PM IST if the user Time Zone is IST.


Similarly for other Time Zones it should display the time accordingly.

Is this possible in SSRS 2005?

Any pointers will be usefull...

Thanks in advance
sudheer racha.

View 5 Replies View Related

Selection

Oct 22, 2003

hello

in the database.....

table:1
DELIVERY_HEADER
INVOICE# PO#
1111 001,0002,0003
2222 005,0006,0007

in one invoice has many po# number i already get the po number individually using explode...
the ouput like this
001
002
003 and so on it is ok for that

but my problem is

i want to the po# should be selected i mean like a menu ..like the user select the which po# should be updated....

but i dont know how..

is there anyone can help me?

to elaborate more...

i can display the po# already without commas like in invoice# 1111
i can already display the po# number like this
001
002
003

after that i want it to be like a menu that user will only select the which po# should be updated..using arrow keys down and up....i mean just like selecting..

but i dont know how..

PLS HELP ME


thank

r3sann

View 1 Replies View Related

Many-to-many Selection

Jan 17, 2006

Hi all, I am stuck on the case of many-to-many selection.

Now, I have 3 tables


Table: candidate_skills
candidate_id (PKey)
skill_id (PKey)

Table: skills
skill_id (PKey)

Table: job_skill_required
job_id(PKey)
skill_id(PKey)


Now, I want to select all cadidates who has the same skills of job_skill_required table.

I really don't know how to select it...
Please help, thank you.

View 5 Replies View Related

Help With The Selection

Nov 16, 2007

SELECT Distinct a.group_code, a.group_name + '-'+ a.group_note As full_name ,
b.station_nbr, b.beg_eff_date, b.end_eff_date,
Round( e.C02_pct,3)As C02_pct, MAX( e.sample_date)As Highest_Sample_Date, d.station_name
from [HOU-TIES01].TIES_Gathering.dbo.group_detail a
Inner Join [HOU-TIES01].TIES_Gathering.dbo.station_group b on a.group_code = b.group_code
Inner Join [HOU-TIES01].TIES_Gathering.dbo.station_type c on b.station_nbr = c.station_nbr
Inner JOIN [HOU-TIES01].TIES_Gathering.dbo.station d ON c.station_nbr = d.station_nbr
Inner JOIN [HOU-TIES01].TIES_Gathering.dbo.gas_analysis e ON d.station_nbr = e.station_nbr
Where (b.station_nbr=e.station_nbr)and (b.group_code = a.group_code) and
(a.group_type = 'NPN')and( b.end_eff_date >=DATEADD(mm,DATEDIFF(mm,0,dateadd(mm,-0-datepart(day,0),getdate())),0))
and ( (c.type_code = 'WHM')or ( c.type_code = 'CRP'))and
(e.sample_date Between DATEADD(mm,DATEDIFF(mm,0,dateadd(mm,-0-datepart(day,0),getdate())),0)
and DATEADD(mm, DATEDIFF(mm,0,getdate()), 0))
and e.seq_nbr =
(select max(x.seq_nbr)
From [HOU-TIES01].TIES_Gathering.dbo.gas_analysis x
Where x.station_nbr = b.station_nbr
and x.sample_date= e.sample_date )
and e.C02_pct =
(Select max(x.C02_pct)
From [HOU-TIES01].TIES_Gathering.dbo.gas_analysis x
Where x.station_nbr = b.station_nbr
and x.sample_date= e.sample_date )
Group by a.group_code, a.group_name, a.group_note, b.station_nbr, b.beg_eff_date, b.end_eff_date, e.c02_pct, d.station_name
order by a.group_code



ok. Here is how the data looks.
Group
code station_nbr beg_eff_date end_eff_date C02 sample_date
0004 D01G000819 2007-09-01 3000-12-31 0.40 2007-10-02
0004 D01G000819 2007-09-01 3000-12-31 2.49 2007-10-09


What I am trying to do is to select the most current sample date. In this case "2007/10/09" when station_nbr and group_code are the same for both dates.

Thank You for all your help!!!!
From the Jr.in SQL

View 4 Replies View Related

I Need Help In How To Use SUM Selection.

Nov 27, 2007

Hi Team:

This is a new query and I am facing a new problem. Here I am requesting all the records for a Contract Number 'GTH00001' for the specific date of 2/2/2007. I want the SUM(c.rcpt_nom_vol)AS Receipt and the b]SUM(c.rcpt_fuel)As Allocated_Fuel[/b]
But Instead I am getting 147 records for Contract Number'GTH00001'for the date of 2/2/2007.


Declare @Req_Contract_nbr char (8),
@Req_Day int,
@Req_month int,
@Req_year int

Set @Req_Contract_nbr = 'GTH00001'
Set @Req_Day = '2'
set @Req_month = '2'
Set @Req_year ='2007'

SELECT Distinct a.contract_nbr,
c.beg_eff_date, c.rcpt_dlvry_ind,
SUM(c.rcpt_nom_vol)AS Receipt, SUM(c.rcpt_fuel)As Allocated_Fuel
from dbo.contract a
Inner Join dbo.NOm b on a.contract_nbr = b.contract_nbr
Inner Join dbo.Nom_vol_detail c on c.Nom_id = b.Nom_id
where (a.contract_sub_type = 'INT') and (a.Contract_type_code ='GTH')
and (DATEADD(mm, DATEDIFF(mm,0,getdate()), 0) < a.current_expirtn_date)
and (c.rcpt_dlvry_ind ='R') and a.contract_nbr= @Req_Contract_nbr
and Day(c.Beg_eff_date) = @Req_Day
and (month(c.Beg_eff_date)= @Req_month )
Group by a.contract_nbr,c.beg_eff_date, c.rcpt_dlvry_ind, c.rcpt_nom_vol, c.rcpt_fuel


Data Example


Contract_nbr specific Date rcpt_nom_vol rcpt_fuel
GTH000012007-02-02 00:00:00.000R4.00.0
GTH000012007-02-02 00:00:00.000R8.00.0
GTH000012007-02-02 00:00:00.000R11.00.0
GTH000012007-02-02 00:00:00.000R12.01.0
GTH000012007-02-02 00:00:00.000R14.01.0
GTH000012007-02-02 00:00:00.000R15.01.0
GTH000012007-02-02 00:00:00.000R16.01.0
GTH000012007-02-02 00:00:00.000R16.02.0
GTH000012007-02-02 00:00:00.000R16.04.0


Thank you for all your help!!!!!!!!! I deeply appreciate all your help.

Osiris
The future depends of what we do in the present- Mahatma Gandhi

View 2 Replies View Related

CheckBoxList Selection

Mar 14, 2008

Hi
I have CheckBoxList to make my selection as follows:if (CheckBoxList2.SelectedValue == "")
{
strSelect = strSelect;
}else if (CheckBoxList2.SelectedValue == "1")if (strWhere == " where")
{strWhere = strWhere + " pic1 = 'true' ";
}
else
{strWhere = strWhere + " and pic1 = 'true' ";
}if (CheckBoxList2.SelectedValue == "2")if (strWhere == " where")
{strWhere = strWhere + " pic2 = 'true' ";
}
else
{strWhere = strWhere + " and pic2 = 'true' ";
}if (CheckBoxList2.SelectedValue == "3")if (strWhere == " where")
{strWhere = strWhere + " pic3 = 'true' ";
}
else
{strWhere = strWhere + " and pic3 = 'true' ";
}
which mean it will addor remove the fields depends upon the user selection, but it will only select one !!
Thanks in advance

View 3 Replies View Related

Calculating The 3rd Value By The First 2's Selection

May 30, 2008

Hi,
First off, let me state that i am new to ASP.net... and have had to hit the ground running... I have looked on the net but have not found a suitable explanation on how to do this.
Let me explain what i am trying to do: In my aspx page, i have 2 dropdown boxes where the user will select a skill catagory, and then a skill. Based on that selection, i would like to compute what the Service line will be. There is a primary and foreign key on CatID on the skills and SkillCat tables. This data would need to be inserted into the another table aswell, and this would need to go into a report later.
How do i go about doing this? Some examples would be greatly appreciated. And if you know of a good link, please post it for me.
 Skills Table









CatID
SkillID
Skills
SL_ID

1
4
Skill 1
3

2
5
Skill 2
2

2
6
Skill 3
2

3
7
Skill 4
4

3
8
Skill 5
4

4
9
Skill 6
NULL

4
10
Skill 7
NULL

5
11
Skill 8
3

6
12
Skill 9
3

7
13
Skill 10
4

8
14
Skill 11
1

9
15
Skill 12
3

9
16
Skill 13
3

10
17
Skill 14
6

11
18
Skill 15
1
Skills Catagory








CATID
Org
Skillcat

1
Org1
Skill Category 1

2
Org2
Skill Category 2

3
Org3
Skill Category 3

4
Org4
Skill Category 4

5
Org5
Skill Category 5

6
Org6
Skill Category 6

7
Org7
Skill Category 7

8
Org8
Skill Category 8

9
Org9
Skill Category 9
 Service Line Table







SL_ID
Service_line

1
Service Line 1

2
Service Line 2

3
Service Line 3

4
Service Line 4

5
Service Line 5

6
Service Line 6

7
Service Line 7
 
Thanks for all your help in advance.
Dash

View 1 Replies View Related

Selection Of Data

Dec 26, 2005

Hi all techies

suppose a table contains these set of values

employeeId          EffectiveDate
1                         2004-12-01
2                         2004-12-01
2                         2005-11-15
3                         2004-12-01


so
1. when i want to select data for the date ranges
(2005-12-01) to (2005-12-31), it should be

1                        2004-12-01
2                        2005-11-15
3                        2004-12-01

2. when i want to select data for the date ranges
(2005-11-01) to (2005-11-30), it should be

1                        2004-12-01
2                        2004-12-01
2                        2005-11-15
3                        2004-12-01

3. when i want to select data for the date ranges
(2005-10-01) to (2005-10-31), it should be

1                        2004-12-01
2                        2004-12-01
3                        2004-12-01What should I do

View 1 Replies View Related

Year Selection In SQL

Dec 4, 2001

Hello Experts,

I would like to have a SQL Statement that to display all records in the same year, e.g., 2001. The date field is a mm/dd/yyyy, smalldatefield.

Could anyone advise the syntax ?

Thank you very much.

View 2 Replies View Related

Processor Selection

Feb 11, 2002

We are looking to purchase a new SQL2000 server.... Tada.... Right then, for around about the same money, we could have either 2 x PIII 1Ghz Xeon with 256Kb cache, or 2 x PIII 700Mhz Xeon with 1Mb cache.... Which choice is best for SQL Server 2000???

View 1 Replies View Related

Help Making A Selection

Feb 25, 2005

I hope I can explain this somewhat coherantly. Here goes..

I have a products database. I want to select product details for items having distinct style codes. IE if there are 20 products that different from one another in some way, and 3 different style numbers throughout them, I want to end up with 3 products selected. I don't care which ones, as long as i have a sample product for each style.
I've attemped to use GROUP BY to do this, but it's not giving me what I want. I managed to get right number of products, but the query seems to have mixed and matched the fields together in an undesireable way. I guess this kinda makes sense, since providing aggregate functions for each of the extra fields is necessary.
SO THE QUESTION IS: How do I select (number of distinct styles) products, and still keep the records in tact as they should be?

Here is a sample...


Code:

SELECT DISTINCT Min(team) as team, min(pict) as pict, min(colors) as colors, min(league) as league, min(product_description) as product_description, min(category) as category, min(subcategory) as subcategory, min(style) as style
FROM prods
WHERE (style='style1' or style='style2' or style='style3')
AND league='leaguex'
AND soldout=''
GROUP by style
ORDER by style




Thanks very much for any help!! I'm sure I'm going about this all wrong.

View 2 Replies View Related

Date Selection

Oct 12, 2005

I want to select a date from a datetime type column.

When I use:

Select ExpireDate from myTable Where ExpireDate > 2005-10-12

...I don't get the correct dates

When I use:

Select ExpireDate from myTable Where ExpireDate > '2005-10-12'

...(with the apostrophe, it works correctly. Is there a way this will work correctly without the apostrophies?

View 1 Replies View Related

Selection Order

Dec 15, 2005

Hi,

Can I assume that SQL Server 2000 will always give the result set of a simple query in the same order as the rows inserted into the table ?

Eg :

select *from test

// there is no order by statement Or TOP clause used. Just a simple select query.

Please advise,

Thanks,
MiraJ

View 5 Replies View Related

Selection Problem

Nov 8, 2006

this is a close question to the prior post but different
pn Amount date billingamt idc
-------------------- --------------------- ------------- ------------ -----------
a7447 .0000 2005-12-28 150.0 10
a7447 .0000 2006-01-09 150.0 11
a7447 .0000 2006-01-10 150.0 12
a7447 50.0000 2006-03-30 150.0 1
a7447 100.0000 2006-04-09 150.0 2
a7447 150.0000 2006-04-16 150.0 3
a7447 150.0000 2006-05-09 150.0 7
a7447 150.0000 2006-05-17 150.0 8
a7447 10.0000 2006-06-16 150.0 15
a7447 150.0000 2006-09-06 150.0 9
a7474 .0000 2006-04-06 185.0 4
a7474 .0000 2006-04-22 185.0 5
a7474 25.0000 2006-04-24 185.0 6
a7474 10.0000 2006-06-16 185.0 16
a7474 50.0000 2006-08-22 185.0 13
a7474 100.0000 2006-09-20 185.0 14


Ok now i need to do is i need to calculate a sum of amount field which equals or less then billingamt for each permit ordered by the date desc

meaning result items should be
a7447 150.0000 2006-09-06 150.0 9

a7474 25.0000 2006-04-24 185.0 6
a7474 10.0000 2006-06-16 185.0 16
a7474 50.0000 2006-08-22 185.0 13
a7474 100.0000 2006-09-20 185.0 14

I can deal with just a count too
as in resulting
a7447 1
a7474 4

I hope the question make sense
i couldnt find any way to do this with out of a cursor any ideas
Thanks

View 12 Replies View Related

Crazy Selection Help

Aug 21, 2007

Hi everyone -

I have two tables, one table (A) that holds a field called location that
has the partial path information of the file

and the second table (B) holds the full path including the filename

I only want to display the records from the partial path (A)
table that do not reside in the second (B) table


Table A =
imagefilename, description, directory, companyname, location
"96.jpg","test","Prog2006_02","Marey, John","Prog2006_0296.jpg"
"274.JPG","disney","Prog2006_07","Amy Gross","Prog2006_07274.JPG"
"570.jpg","sdfsdf","Prog2007_06","Lof3,"Test3","Prog2007_06570.jpg"
"850.JPG","222","Prog2007_08","Malis, Mark","Prog2007_08850.JPG"

Table B =
imagefilename
"d:webdatawebuploadsqfimagesProg2006_0296.jp g"
"d:webdatawebuploadsqfimagesProg2006_03112.p df"
"d:webdatawebuploadsqfimagesProg2006_03127.j pg"

I was thinking about using a cross join with a like condition,
but it fails (go figure)

could someone offer a little help to the query that i need to
perform??

thanks
tony

View 6 Replies View Related

Datetime Selection

Apr 14, 2008

This is my sql query

Select DOJ AS 'JoiningDate' from emp where DOJ like '%2008/09/04%'

there are 8 records on this time.But it displays no result .
The column is datetime datatype
year month date or we need to mention any thing other than this.

View 5 Replies View Related

Tree Selection

Jun 13, 2008

SELECT a.Network_ID, b.Last_Name + ', ' + b.Preferred_FirstName AS full_name, c.Security_Class_Description,
d.Security_Type_Description, a.Security_Value
FROM Company_Hierarchy_Security a
JOIN V_Entity_Employee_Active b on a.Network_ID= b.Network_ID
JOIN Company_Security_Class c on a.Security_Class_Code=c.Security_Class_Code
JOIN Company_Security_Type d on a.Security_Type = d.Security_Type
inner join (select e.Budget_Center_ID + ' - ' + e.Budget_Center_Description As Budget_Center_Description,
f.Company_Name, g.Enterprise_Description, h.Business_Segment_Description,
i.Team_Description
from Company_Hierarchy_Security a.
Inner JOIN Budget_Center e on a.Security_Value = e.Budget_Center_ID
Inner JOIN Company f on a.Security_Value = f.Company_ID
Inner JOIN Enterprise g ON a.Security_Value = Cast(g.Enterprise_Number As Varchar(5))
Inner JOIN Business_Segment h on a.Security_Value = h.Business_Segment_ID
Inner JOIN Team i on a.Security_Value = i.Team_ID


Ok. I have the Security Value located in Company_Hierarchy_Security table. All those values are divided into 5 other tables that I need to join together. I found all of them separate but I have not been able to figue it out how to put it together with the rest of the querie.

Thanks for the help!!!!!

View 3 Replies View Related

Tree Selection

Jun 16, 2008

Thank You visakh16 --- The following section of my querie works but doesn't give the exact information that I need. This is what is giving me:

NetworkId Full Name Sec Class Desc Sec Type Desc SecValue
tte Test Scenario Accounting Budget Center 142- ?



SELECT a.Network_ID, b.Last_Name + ', ' + b.Preferred_FirstName AS full_name, c.Security_Class_Description,
d.Security_Type_Description, a.Security_Value
FROM Company_Hierarchy_Security a
JOIN V_Entity_Employee_Active b on a.Network_ID= b.Network_ID
JOIN Company_Security_Class c on a.Security_Class_Code=c.Security_Class_Code
JOIN Company_Security_Type d on a.Security_Type = d.Security_Type

------------------

inner join (select e.Budget_Center_ID + ' - ' + e.Budget_Center_Description As Budget_Center_Description,
f.Company_Name, g.Enterprise_Description, h.Business_Segment_Description,
i.Team_Description
from Company_Hierarchy_Security a.
Inner JOIN Budget_Center e on a.Security_Value = e.Budget_Center_ID
Inner JOIN Company f on a.Security_Value = f.Company_ID
Inner JOIN Enterprise g ON a.Security_Value = Cast(g.Enterprise_Number As Varchar(5))
Inner JOIN Business_Segment h on a.Security_Value = h.Business_Segment_ID
Inner JOIN Team i on a.Security_Value = i.Team_ID

_____________________________________________________________________

What I need is the Description that are located in 4 other different tables that matches the Security Value from my first querie.

The result should look like this...

Network Id full Name Sec Class Desc Sec Type Desc Security Value
tst , Test Example , Accounting ,Budget Center , 142-Accountig dept


Thank you very much,

View 4 Replies View Related

Selection Problem

Jan 12, 2006

i need some help
i have a database which has single column containing 10,000 records.
i enter a number say 1000.
so it divides the 10,000 records into 10 different column containing
1000 record each.how do i do it?

View 2 Replies View Related

FROM Vs WHERE Selection Criteria

Jan 27, 2006

Hi,

While playing with SQL Server 2000 I found you can specify the selection criteria in either the FROM clause or the WHERE clause:
e.g.
select *
from Table1 a inner join Table2 b ON a.key = b.key and a.field = 1

Is logically the same as:
select *
from Table1 a inner join Table2 b ON a.key = b.key
where a.a = 1

Any comments on which is best, and why?

Thanks,

Chris

View 3 Replies View Related

Selection Query

Sep 21, 2006

Hi All

Being new to this forum and to SQL, I would to apologise upfront for my clumsy code and explanations as I try and get to grips with this subject.

I have created this query which does work:

SELECT T1.U_Serial,
case
when (U_RDate < GETDATE() AND U_ASDate Is NULL)
then 'NA'
when (U_RDate Is NULL)
then 'No Request'
when (U_ASDate Is Not NULL And U_AEDate Is NULL)
then 'NA'
when (U_ASDate Is Not NULL And U_AEDate Is Not NULL)
then 'A'
when (U_RDate > GETDATE() AND U_ASDate Is NULL)
then 'NA'
else 'DN'
end As Available,
case
when (U_RDate < GETDATE() AND U_ASDate Is NULL)
then 'Late'
when (U_RDate Is NULL)
then 'No Request'
when (U_ASDate Is Not NULL And U_AEDate Is NULL)
then 'Busy'
when (U_ASDate Is Not NULL And U_AEDate Is Not NULL)
then 'Done'
when (U_RDate > GETDATE() AND U_ASDate Is NULL)
then 'Waiting'
else 'DN'
end As Progress,

T1.U_Status,T1.U_JobTp, T1.U_JobNr,T1.Code, T0.U_CardNM, T0.U_ZpCd, GETDATE() as Today, T1.U_RDate, T1.U_ASDate, T1.U_AEDate, T1.U_ItemCd, T1.U_ItemDsc

FROM [dbo].[@IDH_JOBENTR] T0 , [dbo].[@IDH_JOBSHD] T1

WHERE T0.Code = T1.U_JobNr AND T1.U_Serial not like ''

ORDER BY T1.U_Serial, T1.U_AEDate DESC, T1.U_JobNr DESC ,T1.Code DESC,Today, T1.U_RDate, Available, Progress, T1.U_Status,T1.U_JobTp,T0.U_CardNM, T0.U_ZpCd, T1.U_ASDate, T1.U_ItemCd, T1.U_ItemDsc

The tables I’m using are IDH_JOBENTR which is the header records for my jobs and IDH_JOBSHD, which holds the row details for the jobs.

I’m trying to extract from the IDH_JOBSHD table the last (row) detail record for the (header) job.

The way the query works now, the first row for each unique serial number is the record I need, but this is all the info I would like to display I don’t need the other lines, and I don't know how to strip out the rest of the data

I hope this make sense.

Kind regards
Hayden

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved