My table has records for every minute, now I want to fetch records with an interval of 5 minutes!
For instance
order date
1 12:01
2 12:02
....
10 12:10
11 12:11
Expected result: Order 6 and 11
Can it be done at database level?
I am using Django with MySQL
...
I have a basic group by/avg statement:
select url, avg(contentping+tcpping), count(*) from websites ws, ping pi
where ws.idwebsite = pi.idwebsite and errortype is null
group by url order by avg(contentping+tcpping) asc;
What I want to do now is to drop any results which have a higher than average ping of 500. How can I do this...?
...
Is there a simple way I can exclude nulls from affecting the avg? They appear to count as 0, which is not what I want. I simply don't want to take their average into account, yet here is the catch, I can't drop them from the result set, as that record has data on it that I do need.
Update:
example:
select avg(col1+col2), count(col3) f...
i have a table that has following column
Type
--------
type 1
type 2
type 3
How can i convert the above to a string like ('type 1', 'type 2', 'type 3')
I want to use the output in my t-sql query with IN clause. Something like select * from TableA where SomeColumn IN ('Type 1','Type 2', Type 3')
I used to following to come up with ou...
I want to rethrow same exception in sql server that has been occured in my try block.
I am able to throw same message but i want to throw same error.
BEGIN TRANSACTION
BEGIN TRY
INSERT INTO Tags.tblDomain
(DomainName, SubDomainId, DomainCode, Description)
VALUES(@DomainName, @SubDomainId, @Domai...
Alright, I'm trying to query a sqlite database. I was trying to be good and use the query method of SQLiteDatabase and pass in the values in the selectArgs parameter to ensure everything got properly escaped, but it wouldn't work. I never got any rows returned (no errors, either).
I started getting curious about the SQL that this genera...
Ok I need to display total talk time of an agent that is coming into SRSS 2005 from SQL 2005 as an INT.
For the life of me I cannot figure out what combination of expression editing or format editing I need to use.
For the detail portion I can use: =DATEADD("s", SUM(Fields!Talk_Time.Value), CDate("00:00"))
And it will return: 1/1/000...
When there are multiple PHP scripts running in parallel, each making an UPDATE query to the same record in the same table repeatedly, is it possible for there to be a 'lag time' before the table is updated with each query?
I have basically 5-6 instances of a PHP script running in parallel, having been launched via cron. Each script gets...
I have a problem using a table with an instead of insert trigger.
The table I created contains an identity column. I need to use an instead of insert trigger on this table. I also need to see the value of the newly inserted identity from within my trigger which requires the use of OUTPUT/INTO within the trigger. The problem is then t...
i try a lot of commands to disable tables constraints in my database to make truncate to all tables but still now it give me the same error
Cannot truncate table '' because it is being referenced by a FOREIGN KEY constraint.
i try
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
EXEC sp_MSforeachtable "TRUNCATE TABLE ?"
...
Hi,
I have a table ClassAttendance and I'm using MSSQL 2005
studentID attendanceDate status
-------------------------------------
*1004 2010-03-17 0
1005 2010-03-17 1
1006 2010-03-17 0
1007 2010-03-17 0
*1004 2010-03-19 0
1005 2010-03-19 ...
I want to call this procedure that sends one value that can be NULL or any int value.
SELECT DomainName, DomainCode FROM Tags.tblDomain WHERE SubDomainId =@SubDomainId
I simply want to use this single query rather than what i m doing right now in below given code.
I searched for this how could i do this then i got this Link.
Accordi...
$sql = 'SELECT
id,
DATE_FORMAT(date,"%d.%m.%Y - %H.%i Uhr") AS dat,
user1,
user2,
p_user1,
p_user2,
be_user1,
be_user2,
win
FROM
kok_1on1_matches
WHERE
user1="$user"
OR
user2="$user"';
What is wrong with the WHERE statement?
...
As someone who comes from the world of Object Orientation, I find it rather difficult to wrap my head around SQL. Recently, however, I realized that the classical SQL construct
select X from Y where Z
is basically equivalent to the following OOP construct:
List<SomeType> results = db.query(new Matcher<SomeType> () {
public boolean ...
The user should input two strings and the script will performe a text search:
$sql = "SELECT * FROM table_one WHERE name='%$str1%' AND MATCH (street, city, pin) AGAINST ('$hrtg'IN BOOLEAN MODE)";
somehow the % does not work, but it alwas did actually. please help?
...
Hi guys, as the comments always have it, you can select to show the top 5 comments (which i know how) and if there is more than 5, you can click a link and it will show the following 5 comments. The problem is that i don't know how the code should be for it to show the next 5.
Better idea of what i'm saying
Let's say i have 10 comments,...
If I have a table like this:
pkey age
---- ---
1 8
2 5
3 12
4 12
5 22
I can "group by" to get a count of each age.
select age,count(*) n from tbl group by age;
age n
--- -
5 1
8 1
12 2
22 1
What query can I use to group by age ranges?
age n
----- -
1-10 2
11-20 2
20+ 1
...
I have a table which has employee relationship defined within itself.
i.e.
EmpID Name SeniorId
-----------------------
1 A NULL
2 B 1
3 C 1
4 D 3
and so on...
Where Senior ID is a foreign key whose primary key table is same with refrence column EmpId
I want to clear all rows f...
by default i have one column in mysql table to be NULL.
i want to select some rows but only if the field value in that column is not NULL.
what is the correct way of typing it?
$query = "SELECT *
FROM names
WHERE id = '$id'
AND name != NULL";
is this correct?
...
Is there a simple way to view the machine generated SQL for SaveChanges() on an Entity Framework context?
...