Pulling Top 3 Within Record Selection

Apr 26, 2007

I need to pull a report that gives me the desired results as show below. I first show the data that is in the table, then below that is the desired result.

What I am trying to do is pull every employee's most recent 3 appraisal Effective Dates within the last 4 years where Rating is different than X.

Sorry I don't reall know how to explain this using code because I seem to be having a block right now. Not sure where to start really.

Any help would be greatly appreciated!! Thanks again!

Records in tblAPPRAISALS Table:

Employee | Appraisal Effective | Rating
A | 1/10/2006 | 5
A | 1/10/2005 | 4
A | 1/10/2004 | 5
A | 1/10/2003 | 5
A | 1/10/2002 | 5
B | 1/10/2006 | 5
B | 1/10/2005 | 5
B | 1/10/2004 | X
B | 1/10/2003 | 5
C | 1/10/2006 | 4
C | 1/10/2005 | 5
C | 1/10/2004 | 5


My current SQL:

SELECT DISTINCT TOP 3 Employee, Appr_Eff as [Appr Effective], Rating_Of_Rcd as [Rating]
FROM tblAPPRAISALS
WHERE Appr_Eff >= DateAdd("YYYY", -4, Date()) AND Rating_Of_Rcd <> "X"
Order by 1, 2 DESC


Results from this Query:

Employee | Appraisal Effective | Rating
A | 1/10/2006 | 5
A | 1/10/2005 | 4
A | 1/10/2004 | 5


Desired Results:

Employee | Appraisal Effective | Rating
A | 1/10/2006 | 5
A | 1/10/2005 | 4
A | 1/10/2004 | 5
B | 1/10/2006 | 5
B | 1/10/2005 | 5
B | 1/10/2003 | 5
C | 1/10/2006 | 4
C | 1/10/2005 | 5
C | 1/10/2004 | 5

View 5 Replies


ADVERTISEMENT

Pulling Data Back From 2 Tables - Join On Top 1 Record

Nov 7, 2013

I have sql pulling back data from 2 tables (Ticket, Assignment) matching on an ID.

however the Assignment table can have more than 1 record for a matching ID in the Ticket table so is bringing back rows for each of these entries HOWEVER i only want 1 row returned matching on the FIRST record in Assignment table (on earliest DateAssigned field)

Here's my code

SELECT t.TicketID, CreatedByUserID, CreatedForUserID, DateCreated, a.DateAssigned FROM Ticket t
INNER JOIN Assignment a ON (SELECT TOP 1 TicketID FROM Assignment
WHERE [TicketID] = t.TicketID
ORDER BY DateAssigned ASC) = t.TicketID

WHERE (CreatedByUserID NOT IN (SELECT u.UserID FROM Users u
INNER JOIN Profiles p ON u.UserID = p.UserID

[Code] ....

View 4 Replies View Related

Random Record Selection

Jul 9, 2007

hello members
i want to no that weathere there is any procedure to select come random records from the database
for eg i want to select 10 students out of 100 randomly
is there any query for this in SQL server 200

View 2 Replies View Related

Delete Record Selection Question

Sep 28, 2005

I'm having trouble with the below sql command.  What I'm trying to
do is to delete records from tblPhotoHeader table where there are no
corresponding child records in tblPhoto.

The select statement works correctly, I'm just not sure about how to
apply the syntax to correctly select the records in the delete
statement.

Any help from the experts here would be helpful.

Thanks

Tom

---------------------------------------------------------------------
DELETE FROM tblPhotoHeader
WHERE      Exists
                         
(SELECT     tblPhotoHeader.photoid, photoOrderID,
tblPhoto.photoType
                           
FROM         
tblPhotoHeader LEFT OUTER JOIN
                                                  
tblPhoto ON tblPhotoHeader.photoID = tblPhoto.photoID
                           
WHERE      (tblPhotoHeader.photoOrderID = 143)
AND (tblPhoto.photoType IS NULL))

View 1 Replies View Related

Automating Record Selection Parameters

Feb 27, 2006

Hi,I need some advise on how to automate record selection on a storedproc. Here is my situation. I have a stored proc that I used onCrystal reports with two parameters - Acctcode and Subacct. When auser enters ' *' on these parameter, it means to report on allaccounts otherwise, report only on specific account.Here is my select statement with line numbers:Create proc rb_SubledgerRpt@Acctcode varchar(4), @SubAcct varchar(3)As3 Select AcctCode, SubAcct4 From GLDetails5 Where SubAcct <> ' '6 and AcctCode = @Acctcode -- for specific acctcode7 and SubAcct = @SubAcct -- for specific subacct8 Go-- If a user wants to see all Acctcode, and all Subacct, how do Idisable lines 6 and 7?Thank you in advance for your help.Edgar

View 6 Replies View Related

I Really Need Some Help, Im Pulling My Fingers Off...

Mar 16, 2006

Ok, to start, i have read SO many posts on this site, and othe sites, and i cannot get this to work.

What i want to do is:
1. Login
2. show an image from a SQL database, based on that login.

I have the image path stored in the database, and i can easily get it
to display on the screen, but it doesnt show the correct image for the
login, it shows them all. (all images based on that column).

I know i have to put a WHERE at the end of my SELECT statement, but everything i have tried doesnt work.

When i do the query builder, and i put in the value, it shows exactly what i want, based on the login's username.

I know i am close, i just can't finish it.


Please help.

Thanks

View 4 Replies View Related

Pulling My Hair Out...PLEASE Help

Aug 1, 2006

Ok so every week I have to download a file containing in excess of 40000 products. I then have to change the category ids to suit my system. Is there a script or something that I could create so I just run it each week to do a search and replace and then loop until all category ids have been changed.

Table = ecommstore
Column = section

I would need to change say from 84 to 1 then 86 to 2, 87 to 3 etc etc

View 12 Replies View Related

Pulling Up A Link

Feb 21, 2008



I have had an unusual request and I thought to ask youreal smart folks out there for a hand.
I am working with a non microsoft application that writes links to an html file. I need to extrapolate the link and pull it into a database table on our MS-SQL 2005 server.
I believe that this woould best be done with a stored procedure.

I guess that I will get the files and save them on a given directory on the W2K3 Enterprise server and run the proceedure there.

All comments are welcome.
Thanks in advance,
Gene

View 6 Replies View Related

Pulling HTML Out Of A Database

Jul 9, 2007

Good Morning,
I'm not quite sure this is the right place to post this, but i'll try anyway.
I have a website where I allow people to create their own layouts in HTML, and in the HTML I have them placeing markers (eg. |1| ) where they would like to place something from a database. All the HTML is stored in a SQL Server DB, and when I pull it out, it's fine, except it won't allow me to Replace any of the markers with values from the DB.
Here's and example line of HTML that's held in the DB:<table width='50%' border='1'><tr><td>|0|</td><td>|1|</td></tr>
 and when I do a strHtml.Replace("|0|", dReader["somefield"].ToString()) or even just a strHtml.Replace("|0|", "Test") it never changes it.
Anyone have any ideas?
Thanks,
Deepthought

View 1 Replies View Related

Pulling Values From Code Behind

Jul 18, 2007

In my code behind file I have this function:
 1 public void getAllSystems()
2 {
3 MTConnection con = MTConnection.CreateConnection(new Credential(new Context("ClearQuest - Boise", "Version 2.0", Micron.Application.Context.Environments.Production), "DSSPROD", Credential.DataSourceTypes.MSSQL, Credential.DataSourceProviders.Odbc));
4
5 string sqltest = " select T1.dbid,T12.systemname AS 'ParentSystem',T1.systemname AS 'SupportSystem',T1.systemstate,T1.features,T3.name,T4.stakeholder," +
6 " T4.fldcolumn_1,T1.systemwebpage,T1.description from ( ( ( ( ( ( ( ( CQ_ADMIN.micronsystem T1 INNER JOIN" +
7 " CQ_ADMIN.microngroup T6 ON T1.primarysupportgroup = T6.dbid ) INNER JOIN CQ_ADMIN.securitygroups T7 ON T1.secuirtygroup" +
8 " = T7.dbid ) LEFT OUTER JOIN CQ_ADMIN.parent_child_links T12mm ON T1.dbid = T12mm.child_dbid and 16778862 =" +
9 " T12mm.child_fielddef_id ) LEFT OUTER JOIN CQ_ADMIN.micronsystem T12 ON T12mm.parent_dbid = T12.dbid )" +
10 " LEFT OUTER JOIN CQ_ADMIN.parent_child_links T3mm ON T1.dbid = T3mm.parent_dbid and 16804095 =" +
11 " T3mm.parent_fielddef_id ) LEFT OUTER JOIN CQ_ADMIN.feature_1 T3 ON T3mm.child_dbid = T3.dbid ) LEFT OUTER" +
12 " JOIN CQ_ADMIN.parent_child_links T4mm ON T3.dbid = T4mm.parent_dbid and 16804263 = T4mm.parent_fielddef_id )" +
13 " LEFT OUTER JOIN CQ_ADMIN.stakeholder T4 ON T4mm.child_dbid = T4.dbid ) where T1.dbid <> 0 and ((T6.abbreviation =" +
14 " 'Test ES Eng Software' and T1.systemstate = 'Active')) and ((T7.dbid in (select parent_dbid from" +
15 " CQ_ADMIN.parent_child_links where parent_fielddef_id = 16778767 and child_dbid in (select child_dbid from" +
16 " CQ_ADMIN.parent_child_links where parent_fielddef_id = 16777328 and parent_dbid = 33664106)and T12.systemname IS NOT" +
17 " NULL ))) order by T3.name ASC,T1.systemname ASC";
18
19 System.Data.DataSet ds = con.ExecuteDataset(CommandType.Text, sqltest);
20
21 foreach (DataRow drCQ in ds.Tables[0].Rows)
22 {
23 string parent_system = drCQ["ParentSystem"].ToString();
24 string child_system = drCQ["SupportSystem"].ToString();
25 //Response.Write(child_system + "<B><I>'S PARENT IS</I></B> " + parent_system + "<BR />");
26 }
27 }
I would like to pull the values of parent_system and child_system into my main page but I don't know how to do that. Is it even possible?Thanks,Xana.
 

View 13 Replies View Related

Pulling Single Lines From A DB

Apr 26, 2004

hi im making a page where i want a single line at a time to be pulled from my MS Database, basically at the moment i have a list of questions, but the page is displaying all the questions from my database, i only want it to pull out 1 and then if the user clicks the true button then it goes to another page and displays another question?

Any ideas

Regards,

Joe

View 1 Replies View Related

Pulling Information From Exchange Into SQL?

Apr 3, 2001

I am looking for something on pulling information from Exchange 5.5 Sp4 to SQL7.0. Anyone know where I can start?
-Stu

View 3 Replies View Related

Pulling A DB Via Remote Admin

Aug 27, 2001

using remote admin program and i need to pul the entire DB onto my local maachine to do some trial runs. I have a static IP so i thought I could just DTS the how system to my computer. Can any one verify that this is the best way of suggest another?
Thanks
Matt

View 2 Replies View Related

Pulling Uniquely When You Can't Use Distinct, Or An ID

May 18, 2006

So here is the problem

I have a table, with an identity in it, I have another table, with that number, it is a one to many relationship.

That table has Fname, Lname inisde of it, some numbers have 1 record, some have 4

Here is the query


Code:


SELECT
FName = ISNULL(UPPER(LTRIM(RTRIM(addr.FName))),'')
, LName = ISNULL(UPPER(LTRIM(RTRIM(addr.LName))) ,'')
, FName2 = ISNULL(UPPER(LTRIM(RTRIM(names.FName))),'')
, LName2 = ISNULL(UPPER(LTRIM(RTRIM(names.LName))) ,'')
, FName3 = ISNULL(UPPER(LTRIM(RTRIM(names.FName))),'')
, LName3 = ISNULL(UPPER(LTRIM(RTRIM(names.LName))) ,'')
, FName4 = ISNULL(UPPER(LTRIM(RTRIM(names.FName))),'')
, LName4 = ISNULL(UPPER(LTRIM(RTRIM(names.LName))) ,'')
, Address1 = ISNULL(UPPER(LTRIM(RTRIM(addr.Address1))) ,'')
, Address2 = ISNULL(UPPER(LTRIM(RTRIM(addr.Address2))) ,'')
, City = ISNULL(UPPER(LTRIM(RTRIM(addr.City))) ,'')
, State = (SELECT StateAbbr FROM ac_States WHERE StateID = addr.StateID)
, addr.Zip

FROM Edina_Class class
LEFT JOIN Edina_Names names
ON names.claimno = class.claimno
INNER JOIN Edina_Address addr
ON class.claimno = addr.claimno
where addr.isactive = 1



What I want is to pull back the unique names, so, if the use only had 1 name, name2-4 would be blank, if the person had 3 names name4 would be blank.

Since "name1" is in the address table, I can pull that one back easy, but what is happening, is the code is taking the first name is finds in the name table and filling in names2 - names4 with it.

I have no idea how to fix the person besides recreating the name to have all of the names per user in 1 record opposed to individual records in the names table.

Hope that made sense.

Thanks

View 5 Replies View Related

Pulling My Hair Out With Locking.

Jan 6, 2006

SQL Server 2000 - Backend
Access 2000 Runtime - Front End
Connecting via ODBC

I have read loads and loads of examples and looked at other sources of info for help on this but am struggleing big time.

I have multiple users working in the same database table. The problem is they often get an error message about the record has been changed and would they like to save the changes to clipboard etc etc.

I basicly want to implement pessimistic locking for my tables. So once a user has started to edit that record nobody else can get to it.

Can anybody help?

Many thanks

View 5 Replies View Related

Pulling Max (date) Not Correct

Dec 21, 2012

Code:
SELECT P.ID, P.QTY, T_DATE
FROM PARTS P
INNER JOIN INVENTORY I ON P.ID = I.PART_ID
WHERE P.QTY > 0 AND I.CODE = 'R'
GROUP BY P.ID, P.QTY, I.T_DATE
HAVING MAX(T_DATE) !> DATEADD(MONTH,-12,GETDATE())

[Code] ....

I am trying to make the sql only pull records where the highest date stored is older than a year ago.

So, based on today's date 12/21/2012:

if the highest (max) T_DATE is 3/12/2012 => don't pull that record
if the highest (max) T_DATE is 11/30/2011 => pull that record into the recordset

the statement is off, it is pulling records that should not be included.

View 4 Replies View Related

Replication (pulling A Subscription)

May 19, 2004

I am trying to pull subscription for a database but I always get the error message ...
Error 15004: Name cannot be null
What exactly have I done wrong
Plaese help
Thanks
Nneka Echebe

View 1 Replies View Related

Pulling Out PO# From The Rest Of The Job Descrip.

Apr 29, 2008

Hello, I am new here and to sql so please bare with me.

I am trying to create 2 select statements from the same field. The field is a job_description field that sometimes contains PO#'s. One select statement needs to extract the PO# if it has been written in the field and the other needs to extract all data that is not the PO#


Here is some example of the data:


New shirts for 2007
Magazine cover for may edition
Way to go postcards PO# 45687
PO#879


For the first select statement I need to capture just the PO#. the result for the above examples would be:

NULL
NULL
45687
879

For the second select statement I need everything but the PO#. The result would be:

New shirts for 2007
Magazine cover for may edition
Way to go postcards
NULL

So far I have put together a basic idea for the PO# part:

(SELECT SUBSTRING (job_description , (SELECT patindex('%PO#%', job_description)+3),10)WHERE job_description LIKE '%po#%')

If i could figure out a way to only return numeric data from the above i think it will work.

As for the second select statement i am at a loss on how to select everything but the PO#.

Any help at all is very much appreciated.

Thanks

View 2 Replies View Related

Pulling Data With Apostrophe

Aug 6, 2013

I am having a problem trying to pull data that has apostrophe in them. How can I do this? I get this as an error

Msg 105, Level 15, State 1, Line 14
Unclosed quotation mark after the character string ''.

Select
Name
From Table
Where Name IN (CHILDREN'S ANES ASSOCS-CHOP,CHILDREN'S HEALTHCARE-CHOP,CHILDREN'S PSYCH ASSOC-CHOP,CHILDREN'S SURGICAL ASSOC-CHOP)

View 4 Replies View Related

Pulling Progress Data

Jun 26, 2006

I'm trying to pull data from about 30 progress databases using DTS andscheduling the jobs to run monthly. I'd like to pull data betweenspecific dates, but for some reason, I can't figure out how to filterthe data on the progress side.I want to run a query that will pull all data fromprior-month/8/current-yearandcurrent-month/15/current-yearI'll also have to account for when it's january, make it december ofthe year before.Any ideas?thanks,M@

View 1 Replies View Related

Need Advice (pulling My Hair Out)

Apr 2, 2007

I am the only DBA for a company of about 200 employees which makes about 100 million a year; I have 8 SQL servers some with over 70 databases on them that feed our web sites and educational web sites. I also have a few databases that are between 75 and 120 Gig that is for our circulation system. I am the Systems admin for all of the systems that run of my SQL server, so that makes our circ system, tradeshow system, accounting system, web sites there are about 90 of them or so. I also do programming for our IT department and some web site stuff as well as for our tradeshow dept. I am the answer man for our sales people and programmers, I also have the knowledge to build by own servers and run a network. So that€™s over 200 databases plus all the other *** that I do. Oh and by the way I'm supposed to help out and cover for our Tec support guys, witch there are 2 of them by the way. I can never take any more than 3 days off at a time; I have a month€™s vacation. I do all this for under $55,000 a year. I am never included in any decisions on software that runs on SQL nor am I consulted on any thing having to do with SQL. I work for a director who knows nothing about SQL server. There are 2 JR data guys and they do just data queries and deal with the day to day circ requests. These guys both have an office not to mention the tech guys have an office and guess what I am in a cube. I asked my boss for a laptop with a Verizon air card so when I€™m not at work if something happens that needs my attention I do have to drive to work or go home and remote in, here is the best part he looked at me and asked if I was high. I am on call 24/7 365. I have over 10 years experience working with SQL. I€™m I crazy for staying? I have been with this company for almost 8 years; I am the one who started them out on SQL server. I have converted every thing over to SQL 98.5% of all the company data I am in charge of. What would you do?

View 6 Replies View Related

Problem Pulling From Access DB

Mar 23, 2007

We are currently moving existing SSIS packages from one server to another. The former server is 32 bit and the new server is 64 bit clustered (not sure if that's relevant or not, though).

One package in particular is giving me a headache. It pulls from an access file to sql server 2005 table. We set up the security as don't save senstive and put the connection strings in a config file. We had to set the original job up to run the package step under a proxy account to get it to work.

If we right click on the package through the SSIS Store interface and execute it runs fine. However when we try to run it through the scheduled job, it fails. I very much appears to be a permissions issue on the proxy account. The person setting up the server is somewhat new to the area of SQL Servers, so they cannot provide much feedback. We're very much in a tweak until it works position, unfortunately.

Here are the errors that I am getting, one from the history of the job, one from the SQL Server logging. Does anyone have a suggestion, and if it is a permissions issue, where to look? I've been at this for days, so I've tried several different approaches. It seems like right now that I almost got it to work, but it seems like the connection to the access db is failing. But if that's the case, why does it run fine through the proxy on the original server (using same account)? I guess that very well could come down to the 64 bit problem (saw this on some other posts). I should mention that I set up the package as Run64BitRuntime = false. Do I need to rethink this as a batch file using DTExec? That was actually our original solution on the former server, but we could never get to work.

Job History Error:

DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "Cost_WorkDB" failed with error code 0xC0202009. There may be error messages posted before this with more information on why the AcquireConnection method call failed. End Error Error: 2007-03-23 16:19:14.92 Code: 0xC0047017 Source: Data Flow Task DTS.Pipeline Description: component "OLE DB Source" (1) failed validation and returned error code 0xC020801C. End Error Progress: 2007-03-23 16:19:14.92 Source: Data Flow Task Validating: 100% complete End Progress Error: 2007-03-23 16:19:14.94 Code: 0xC004700C Source: Data Flow Task DTS.Pipeline Description: One or more component failed validation. End Error Error: 2007-03-23 16:19:14.94 Code: 0xC0024107 Source: Data Flow Task Description: There were errors during task validation.... The package execution fa... The step failed.


sysdtslog90 error:

SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "Cost_WorkDB" failed with error code 0xC0202009. There may be error messages posted before this with more information on why the AcquireConnection method call failed.

component "OLE DB Source" (1) failed validation and returned error code 0xC020801C.

View 5 Replies View Related

How To Format A String When Pulling From A Dataitem

Mar 24, 2006

    I seem to be having a problem in getting a string formatted correctly that I'm pulling from a SQL Datasource.I'm trying to format a Datalist, and more specifically, a Paypal "Add to Cart" button that's supposed to pass several values to another page.  The problem I have is with passing the price amount.  All the data is in a SQL Express database and the price field is in the database as "money".  However it outputs the dollar amount with too many trailing zeros, for example $6.00 is formatted as 6.0000.  I'm trying to pass it into the form variable with this code:<input type="hidden" name="amount"  value="<%# DataBinder.eval(Container.dataitem, "Price", "{0}" %>">Unfortunately, that tends to make include the trailing zeros and mess up the ability to pass the variable.  Can anyone help me with how to format this variable so there's no trailing zeros, just so that $6.00 comes out as 6.00 and not 6.0000?Thanks

View 2 Replies View Related

Question About Pulling A Max Value On A Date For On Specified Criteria

Dec 20, 1999

Ok...
Here is what I want to to:
I have a number of tables, but this query concerns only two of them: Employee, Disposition, with a one to many relationship on the phone number.. Employee has personal info, and dispostion is a large table that keeps track of transactions. There is a unque_id for every transaction.

I want to pull some information. A date is assciated with each trans action on the disposition table. I want to be able to pull up all the unique employee phone numbers from a disposition table but only the latest date they made a transaction. My result should be only one phone nbr, one transaction number, and the date of the last transaction, per employee phne_nbr. But I can't seem to be able to pull this.

This query gets me the max date called per phne_nbr:

select 'Max'= max(dte_call), phne_nbr into TestTable
from Disposition
group by phne_nbr

The problem arises when I need to get the unique_id for that transaction, as I need it for other queries...The code below does not work...I get duplicate records and so forth.

select 'Max'= max(dte_call), phne_nbr, unique_id into TestTable
from Disposition
group by phne_nbr, unique_id

This shouldn't be that hard!! (((I tried a variation usin select distinct with the filed I wanted to be distinct in () otherfield, other field... but the distinct is not limited to the field in (), it gets the distinct record for the entire select ))) I must be missing something simple here. Can anyone help!!!

View 2 Replies View Related

Pulling Data From Xls Thru' Query Analyzer!

May 21, 2004

Hi MAK,

I got this piece of code from one of your articles:

select * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;DATABASE=c: est.xls', 'Select * from [Book1$]')

Question is, how can I use a fully qualified path for the xls file name if the file is located on the network elsewhere?is that possible with this option?

Thank you!

View 2 Replies View Related

Pulling Out Data From MSAS Cube

Dec 12, 2005

Hi friends,
I am new to MSAS world. I need help related to this. I want to pull data from MSAS cube programmatically. Only way I know is thru ODBO, but that won't help me in this case, cause I might have to drill down upto all possible intersections stored in MSAS (at least all of the stored members). Doing this thru MDX could be humongous thing, at least manipulating data taken out using ODBO.
I might be missing something out here. Can anybody help. It would also help if somebody can tell me if any other approach is poosible.

Thank you.
Abhijeet

View 3 Replies View Related

Pulling The Data From SQL Server6.5 To SQL Server2000

Aug 30, 2001

Can any one tell me how to transfer bulk data from SQL Server6.5 to SQL Server2000.I have tried bcp out and bcp in to SQL Server2000 but it is taking very long time.Is there any way that I can pull the data into SQL Server2000 from SQL Server6.5.Can I use DTS feature of SQL Server2000 to pull the data from SQL Server6.5..

View 2 Replies View Related

SSIS Not Pulling Data Correctly

Feb 26, 2008

Ok I wrote a SSIS package that will pull down data from my AS/400 and populate a SQL Server table with the data.

1)The data is being pulled from my China configured AS/400. It is configured to handle DBCS
2)The SQL Server tables are configured to handle DBCS by using the nvarchar datatype.
3)When I run this package on my machine against the production server, it works perfectly.
4)When I run this package on my test SQL Server against the production server,it works perfectly.
5)When I run this package on my production SQL Server it brings down all the records, but does not bring down all the fields. Most of the character fields are left blank.(not all)

I do not understand why this is doing this. Can anyone shed any light on this problem? Thank you.

View 2 Replies View Related

Pulling Data Into One Line (Aggregation)

Aug 19, 2015

eventually I started using DERIVED Tables and Sub queries within them if needed. I like choking down all the queries in the selects joining them and having your result set select there to choose from all the aliases, it also resolves while doing this. So much easier IMO than using CTE's or TEMP Tables. I was big on temp tables for a while...

I'm curious though if you want to count a type of criteria in a column do you use a standard case in your inner query choking it down just for those particular counts? Then do another case on the other criteria and END AS with the alias name?

E.G.

CASE WHEN COLUMN1 = PIZZA THEN COUNT(COLUMN1) END AS PIZZACOUNT
CASE WHEN COLUMN1 = ROOTBEER THEN COUNT(COLUMN!) END AS ROOTBEERCOUNT
ETC...........

View 4 Replies View Related

Pulling Unique Records With Max Dates

Mar 5, 2006

I am trying to pull only those records with a maximum upload date for a file upload log.

This table keeps a list of files uploaded by supplierID and will have multiple records from the same supplier but with all different upload dates. Overall there are over 1,000 records for 48 uniqur suppliers.

The field names are:
SupplierID, UploadDate, FeedFileName, RecordCount, FeedFileDate, RecordCount, and FeedLoaded.

So for each distinct SupplierID I'd like to grab the line item based on the max feedfiledate for each one - in other words I am trying to get the latest uploaded file information, how many records were in the file, and when it was uploaded... I've tried multiple group by and max clauses but there is something I am missing...

Thanks Much in advance

View 4 Replies View Related

Sql - Pulling Data From Specific Rows

Nov 12, 2006

I have a table, multiple columns, thousands of rows.

Six of the columns is the data that i need to work with...

col1, col2, col3, col4, col5, col6

col1 and col2 - go together - example. col1 = amount col2 = description
col3 and col4 - go together col3 = amount col4 description
col5 and col6 - go together col5 amount and 6 description

i need to pull search the table based on an auto number "id" and pull in the necessary two columns that correspond with a set value in the description.

example:

if col4 has "fee applied" in the description i need to pull the amount.

Please help...

Thank you in advance

View 3 Replies View Related

SSIS Not Pulling Data Correctly

Feb 26, 2008

Ok I wrote a SSIS package that will pull down data from my AS/400 and populate a SQL Server table with the data.

1)The data is being pulled from my China configured AS/400. It is configured to handle DBCS
2)The SQL Server tables are configured to handle DBCS by using the nvarchar datatype.
3)When I run this package on my machine against the production server, it works perfectly.
4)When I run this package on my test SQL Server against the production server,it works perfectly.
5)When I run this package on my production SQL Server it brings down all the records, but does not bring down all the fields. Most of the character fields are left blank.(not all)

I do not understand why this is doing this. Can anyone shed any light on this problem? Thank you.

View 6 Replies View Related

Pulling All Dates Within A Date Range

Jul 6, 2006

I am currently working in the sql server 2000 environment and I want towrite a function to pull all dates within a given date range. I havecreated several diferent ways to do this but I am unsatisfied withthem. Here is what I have so far:declare @Sdate as datetimedeclare @Edate as datetimeset @SDate = '07/01/2006'set @EDate = '12/31/2006'select dateadd(dd, count(*) - 1, @SDate)from [atable] vinner join [same table] v2 on v.id < v2.idgroup by v.idhaving count(*) < datediff(dd, @SDate, @EDate)+ 2order by count(*)this works just fine but it is dependent on the size of the table youpull from, and is really more or less a hack job. Can anyone help mewith this?thanks in advance

View 3 Replies View Related







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