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 Wanet Telecoms Ltd 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: *

  • Users: Geoka
  • Order by date
  1. Geoka

    COUNT is wrong when linking 2 tables

    Correction. The second field should title should be 'RE Count'. Same name for 2 fields are not possible. SELECT Product, Count(CASE WHEN LEFT(a.JobNo,2) = 'DA' THEN 1 else 0 END) AS 'DA Count', Count(CASE WHEN LEFT(a.JobNo,2) = 'RE' THEN 1 else 0 END) AS 'RE Count' FROM tblLift a LEFT JOIN...
  2. Geoka

    COUNT is wrong when linking 2 tables

    Try this code. I haven't tested it. SELECT Product, Count(CASE WHEN LEFT(a.JobNo,2) = 'DA' THEN 1 else 0 END) AS 'DA Count', Count(CASE WHEN LEFT(a.JobNo,2) = 'RE' THEN 1 else 0 END) AS 'DA Count' FROM tblLift a LEFT JOIN tblJobMethods b ON a.JobNo = b.JobNo GROUP BY a.Product George
  3. Geoka

    sql command to list references to table or view?

    You may want to look at INFORMATION_SCHEMA.VIEW_COLUMN_USAGE select * from INFORMATION_SCHEMA.VIEW_COLUMN_USAGE
  4. Geoka

    how to code to delete empty rows

    Try the below code. Note:If 10 contineous blank cells will stop the execution. Sub Button1_Click() mRow = 1 nCnt = 0 While True If Trim(Sheet1.Cells(mRow, 1)) = "" Then Sheet1.Cells(mRow, 1).Delete nCnt = nCnt + 1 If nCnt = 10 Then 'If 10 contineous blank cells...
  5. Geoka

    Beginner- Needs sql multi-query help

    Larry, Why don't you try the inner query alone specified by Ryan and see the output matches your requirement. The solution provided by Ryan will returns 10 as total count and 3 as offsite count. As long as discovered_offsite_date used in the subquery, the DISTINCT operator will check that...
  6. Geoka

    Pass a variable for IN statement

    You can achieve this by Dynamic SQL, here is one small sample. Filter condition applied on String field declare @MyVar varchar(100) declare @newvar varchar(1500) set @MyVar = '~155A06420~,~151A06420~,~515A06607~' set @newvar = 'select * from MyTable where MyCol in(' +...
  7. Geoka

    business day calculation

    This might help you. Instead of msgbox you can assign it to a variable and use it. msgbox (DateAdd("d",15,DTPicker1.Value))
  8. Geoka

    Creating query that lists a series of derived dates

    The below code might give you some idea. select * from #test Select dateadd(day,A.number, T.fDate ) From #Test As T Inner Join ( Select Number From master..spt_values Where Type = 'P' ) As A On dateadd(day,A.number, T.fDate ) Between...
  9. Geoka

    SQL Server work load

    I have some sql script(complex), which will take too much time because of the data. It has to run on a daily basis. I have scheduled this for every morning,at the same time some other sql scripts are also execute in the same server. So my sql script timed out mostly. It will run some days...
  10. Geoka

    Question on @@ROWCOUNT

    My mistake, I pasted wrong code. Updated code is given below. SELECT @@rowcount as TotalCount,HCID FROM ( SELECT HCID FROM prod_SPBILL_SSA_Invoice_Entry WHERE Status <> 'G' and (CancelledStatus ='N' or CancelledStatus is NULL) UNION SELECT...
  11. Geoka

    Problem with screen / resolution

    If the exe is calling from a DOS BATCH file, you could achive it by giving the following line of code just before the EXE call. mode con cols=80 lines=24
  12. Geoka

    Question on @@ROWCOUNT

    I have a question on the scope of @@ROWCOUNT. I have a Select statement used in my Stored Procedure, which is given below. I would like to know whether it will return the desired results all the time or any possibility of showing wrong result on multi user environment. About my requirement...
  13. Geoka

    Accumulation of row values in a specific column

    Small correction in the code for fixing the ID field. It should be like running sequence number. DECLARE @Test TABLE (Id int, Value int) INSERT @Test VALUES (1, 2) INSERT @Test VALUES (2, 4) INSERT @Test VALUES (4, 5) SELECT count(ISNULL(Tbl1.id,0)) AS id, SUM(ISNULL(Tbl1.Value,0))...
  14. Geoka

    Convert text to date

    if the field in your table is datetime , then there is no need to convert to dd/mm/yyyy format. You can directly use '20040401' in your filter condition.
  15. Geoka

    Execute Statement

    More over, need to qualify ownername before the function. for example - dbo.fMyFunction
  16. Geoka

    Execute Statement

    It is because you have used set QUOTED_IDENTIFIER ON statement in your code.
  17. Geoka

    Select Min Values and Max Count

    Select Top 1 Store, count(Item) Item, min(avgscore) avgscore from Stock group by store Order by Item Desc, avgscore Asc
  18. Geoka

    changing float value

    update TestTable set Amount=Amount/1000
  19. Geoka

    Find MIN but dont show it

    if min of ORDERNO for each JOBNO always same then better use code suggested by PatriciaObreja for performance.
  20. Geoka

    Find MIN but dont show it

    One simple way is given below. Didn't checked the performance. select b.jobno, a.value from testing a inner join (select min(orderno) orderno, jobno from testing b group by jobno) b on a.orderno=b.orderno and a.jobno=b.jobno

Part and Inventory Search

Back
Top