Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. amrita418

    SQL Query

    Yes, when both the datatypes in the where clause are of datatype varchar your result set could be messy. What does this get you? select convert(datetime, convert(varchar, month(SQLTranDate)) + '/01/' + convert(varchar, year(SQLTranDate))) as Year, sum(SQLTranAmt)...
  2. amrita418

    SQL Query

    3 Questions: 1) Do you have any data after 2006 Jan? 2) What is the datatype of SQLTranDate? 3) What database are you using?
  3. amrita418

    SQL Query

    The Year field actually has date format so would see something like '2006-02-01 00:00:00.000' (one record per each month-year combination. Isn't this the output you expected? Year Total 2006-02-01 00:00:00.000 93 2006-03-01 00:00:00.000 1679 2006-04-01...
  4. amrita418

    SQL Query

    Try this: select convert(datetime, convert(varchar, month(SQLTranDate)) + '/01/' + convert(varchar, year(SQLTranDate))) as Year, sum(SQLTranAmt) as Total FROM chart1 where SQLTranDate >= convert(varchar(10), dateadd(day, -day(getdate()) + 1...
  5. amrita418

    SQL Query

    lannym, Can you post the query you are running? You should not get data older than 12 months with the query I posted so not sure how you are getting 2005 data. Also, the only month you would see twice in the output would be feb because I did not filter current month. Do you want that filtered...
  6. amrita418

    SQL Query

    lannym, This definitely is not the most elegant solution but should work. select month([SQLTranDate]) as Month, year(SQLTranDate]) as Year, sum([SQLTranAmt]) as Total FROM chart1 where [SQLTranDate] >= convert(varchar(10), dateadd(day, -day(getdate()) + 1, dateadd(month, -12...
  7. amrita418

    Question an update using case or an if statement

    UNCMoochie, Your code was correct, but order of the conditions in the case statement was wrong. <b> update #T1 set yr_joined = case when s98 > 0 then '1998' when s99 > 0 then '1999' when s00 > 0 then '2000' end </b> Best Regards, AA
  8. amrita418

    Updating fields from one table into another

    Try this: Update w set w.dept_num = t.dept_num, w.dept = t.dept from workstat w inner join tiuser t on (w.userid = t.userid) Regards, AA
  9. amrita418

    Group by for string concatenation

    Try running the udf solution with the following query instead: select product, dbo.udf_test_name_ret(product) from test group by product Regards, AA
  10. amrita418

    Extracting Maximum Call History

    There are several ways to do this. One such idea would be: SELECT call_number, History, Current_Group FROM #TableA a, (SELECT call_number, MAX(History) max_history FROM #TableA GROUP BY call_number) b WHERE a.call_number = b.call_number and a.history = b.max_history...
  11. amrita418

    Incremental Count

    How about something like this? select acct, dates, att from DTWDTA.DWFLTH1 a where dates in (select top 5 b.dates from DTWDTA.DWFLTH1 b where a.acct = b.acct...
  12. amrita418

    Finding unused identities

    I would suggest to avoid cursors whenever possible. Here is a snippet to get you started: create table #Test (Name varchar(10), Id int) insert into #Test values ('a', 1) insert into #Test values ('b', 4) insert into #Test values ('c', 5) insert into #Test values ('d', 8) insert into #Test...
  13. amrita418

    Primary key column alteration

    Try the following: Drop the primary key constraint. Alter the data type of the column as desired. Add the primary key constraint back. Best Regards, AA
  14. amrita418

    Primary key column alteration

    Can you be more specific on what you are trying to do? Did you look at dropping a constraint? Best Regards, AA
  15. amrita418

    Insert the same column data to another column of the same table

    Try this: update Orders set telephone_contact = telephone Best Regards, AA
  16. amrita418

    How to select correct FILL FACTOR

    There is no set formula for calculating the fill factor. check this link. Regards, AA
  17. amrita418

    data merge

    You can use DTS to copy tables/data by checking all tables applicable. Regards, AA
  18. amrita418

    Is it possible to use a case statement to then execute a procedure?

    No. Use If/Else block to do something like this. Declare @type Int Set @type = 27 If @type = 25 Exec sp_help YourTable Else Print 'Value for Type is ' + Convert(Varchar(5), @type) Regards, AA
  19. amrita418

    counting nulls and blank fields together

    Not sure why an inline view is needed here? select campaignname, case when status is null or status = '' then 'approved' else status end, sum(occurence) from #blah group by campaignname, case when status is null or status = '' then 'approved' else...
  20. amrita418

    Datetime manipulation question

    If you are looking for a statement that dymically calculates returns Monday, Friday dates then try this: DECLARE @dd datetime SET @dd = '09-26-2005' select case when datepart(dw, @dd) = 2 then convert(varchar(10), @dd, 101) when datepart(dw, @dd) = 3 then convert(varchar(10), @dd -...

Part and Inventory Search

Back
Top