How do I get the first day of a given week whose week number is available? For example as I write this post we are at WEEK 29.I would like to write a MySQL query that will return Sunday 18 July using this WEEKNO 29 as the only available parameter. Answer You can use: This would give you the Monday
Delete duplicate records in SQL Server?
Consider a column named EmployeeName table Employee. The goal is to delete repeated records, based on the EmployeeName field. Using one query, I want to delete the records which are repeated. How can this be done with TSQL in SQL Server? Answer You can do this with window functions. It will order the dupes by…
Excel 2003 send date parameters to SQL query
I have a few worksheets that use sql queries to retrieve data. I would like all of these sheets to query data based on the same date range entered by a user in excel. eg. I would enter somewhere in a form or in a cell a date range and retrieve the value in sql to obtain data based on
MS Access Pass Through Query find duplicates using multiple tables
I’m trying to find all coverage_set_id with more than one benefit_id attached summary_attribute (value=2004687). The query seems to be working fine without the GROUP BY & HAVING parts, but once I …
SQL syntax for “if exists”
Why I’m getting this error: My SQL query: Thanks. Answer IF EXISTS only works in a stored procedure. Outside of a stored procedure, IF() is a function which takes 3 arguments. Proper usage would be
DataReader.GetString() via columnname
Dictionary Fields = new Dictionary(); for (int i = 0; i < reader.FieldCount; i++) { Fields.Add(reader.GetName(i), i); } this._MyField1 = reader.GetString(Fields[“field1”]); this._Myfield2 = reader.GetInt16(Fields[“field2”]); doing this makes me want to cry but i can’t seem to …
Case expressions may only be nested to level 10
I have the following code for handling phone numbers such as country code for Australia +61, 61, 001161 etc. The problem that I have I can’t insert any CASE statement anymore under: CASE WHEN LEFT(@BPartyNo, 4) = ‘+610’ It said that Case expressions may only be nested to level 10 How do I st…
sql query: select people with same name ascending by age
Have 2 table 1st {id_city,name } 2nd table {id_ctz,name,sname,age,id_city} need selected full information (name(city),name,sname,age) people with same name ascending by age? Have tried: select …
MySQL update statement to store ranking positions
I’m trying to get my head around a query and I just can’t figure it out. I would appreciate if someone give me a pointer. As a simple example of what I’m trying to achieve, I have these records in the …
Change a Nullable column to NOT NULL with Default Value
I came across an old table today with a datetime column called ‘Created’ which allows nulls. Now, I’d want to change this so that it is NOT NULL, and also include a constraint to add in a default …