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 strongm 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. chamilz

    Can't get thousands seperator to work in SQL error

    SELECT ChgBillMonth ,CONVERT (VARCHAR(100),SUM(CAST(ChargeAmt as Money)),1) as ChargeAmt ,sum(CurrentBalance) as Balance ,sum(ChargeAmt) as ChargeAmtSum --,sum(CurrentBalance) as Balance FROM #T WHERE ChgBillMonth='8/1/2013' GROUP BY ChgBillMonth
  2. chamilz

    Scrape data between brackets - []

    select substring(YourColumn,charindex('[',YourColumn)+1, charindex(']',YourColumn)-charindex('[',YourColumn)-1) from YoutTable
  3. chamilz

    need help with SQL statement to get counts managers of managers of managers

    check this out... http://msdn.microsoft.com/en-us/library/ms186243%28v=sql.105%29.aspx
  4. chamilz

    Scrape data between brackets - []

    select substring(YourColumn,2,len(YourColumn)-2) from YourTable
  5. chamilz

    Adding Group Columns

    if it is SQL 2005, use CTE with Detail(empcount,busunitdesc) as ( select count (distinct employeeid), busunitdesc from invinvoicedetail inv inner join invinvoiceheader b on b.invoiceid = inv.invoiceid inner join ssbusunit u on u.busunitid = inv.busunit where b.invoicedate between @StartDate...
  6. chamilz

    Set Theory for beginning database developers?

    this book helped me to explore more behind the T-SQL http://www.amazon.com/Inside-Microsoft-SQL-Server-2005/dp/0735623139#readerhttp://www.amazon.com/Inside-Microsoft-SQL-Server-2005/dp/0735623139#reader
  7. chamilz

    Multi Part Identifier Could Not Be Bound

    in your derived table 'Month(dteEffectiveDate)' column has been defined as 'Monthy' and AVG(nbrFuelSurcharge) as 'FSCY'. run this code alone and see the output and columns SELECT 'Monthy'=Month(dteEffectiveDate), 'FSCY'=AVG(nbrFuelSurcharge) FROM Mother.dbo.tblFuelSurcharge GROUP by...
  8. chamilz

    Multi Part Identifier Could Not Be Bound

    ( SELECT 'Monthy'=Month(dteEffectiveDate), 'FSCY'=AVG(nbrFuelSurcharge) FROM Mother.dbo.tblFuelSurcharge GROUP by dteEffectiveDate ) AS tbl
  9. chamilz

    Convert Decimal to Int

    That was very informative George. I wasn’t sure that there is a workaround to convert data type using CASE so i thought that my logic was wrong. So i built that logic at the report level. Thanks for the suggestion.
  10. chamilz

    Convert Decimal to Int

    Thanks jbenson001 for pointing that error!!
  11. chamilz

    Convert Decimal to Int

    Hi, I want to format the data as below for a report. here is just a sample of what i am doing... create table #test (Header_1 varchar(20), Month_1 numeric(10,2)) ; insert into #test values('Sales',120) insert into #test values('Sales%',2.45) ; select case when charindex('%',[Header_1])=0...
  12. chamilz

    Strange Timeout expired error

    instead of ConnectionTimeOut = 0, try using CommandTimeOut=0 cmd.CommandTimeOut = 0 cmd.ExecuteNonQuery()
  13. chamilz

    Help with Min()/Grouping

    MikeBinKC, I think SQLSister explained it clearly. you can further read about derived table here.. http://www.sqlservercentral.com/articles/Performance+Tuning/derivedtablebasics/597/
  14. chamilz

    Help with Min()/Grouping

    try this... select a.EmployeeName, a.LeadName, a.PhoneNumberCalled, a.DateCalled from MyCallRecord a inner join ( select EmployeeName, LeadName, min(DateCalled)DateCalled from MyCallRecord group by EmployeeName,LeadName ) b on a.EmployeeName =...
  15. chamilz

    RE: Pivot Table ??

    this might help you. thread183-1459723
  16. chamilz

    Parsing name field to obtain Last name, first name

    This may help you... http://www.sql-server-helper.com/tips/split-name.aspx
  17. chamilz

    How do I sum the results of two queries?

    you could try this. select a.AccountRef_FullName,sum(a.SumTotal)SumTotal from ( 'your first query' union all 'your Second query' ) a group by a.AccountRef_FullName
  18. chamilz

    Query for Top N for large amount of data

    if it is SQL 2005, you could try this. i used multiple CTEs along with the ROW_NUMBER() function. with SALES1 as ( select SalesPerson,State,sum(Cost) Tot_Cost from InvoiceTable group by SalesPerson,State ), SALES2 as ( select SalesPerson,State, row_number() over(partition by State order by...
  19. chamilz

    Distint Select & Count Across Tables?

    it should be group by a.NumID
  20. chamilz

    Distint Select & Count Across Tables?

    try this.. select distinct a.NumID, count(b.NumID)NumID_Count from Table_1 left join Table_2 on a.NumID = b.NumID group a.NumID DISTINCT command gives you only unique records based on the columns you have defined. Column list (NumID,Date,Item,Item2) is NOT unique, qry returns duplicate...

Part and Inventory Search

Back
Top