« first day (1662 days earlier)      last day (2656 days later) » 

6:52 AM
hi guys
Any idea on this error
An expression of non-boolean type specified in a context where a condition is expected, near 'MATCHES'.
 
 
1 hour later…
8:18 AM
morning
 
 
1 hour later…
9:46 AM
hi guys
Any idea on this error
An expression of non-boolean type specified in a context where a condition is expected, near 'MATCHES'
 
hello I have in database 4 entries with time 10:00 - 10:15, 10:15 - 10:30, 10:30 - 10:45, 10:45 - 11:00 can I group them into one if have 15minutes diff?
 
@tHiNk_OuT_oF_bOx which db are you using?
 
sorry if start time is == with prev end time or if end time is == start time of next
 
@KrisGroove not sure to totally understand
 
one moment
10:00 - 10:15, 10:15 - 10:30, 10:30 - 10:45, 10:45 - 11:00 => 10:00 - 11:00
10:00 - 10:15, 11:00 - 11:15 => 10:00 - 10:15, 11:00 - 11:15
@AndyK
 
9:54 AM
@KrisGroove
sure
which db are you using?
 
Postgres
 
SQL Server 2008
@AndyK
 
@KrisGroove you need a group by function
to deal with that
and probably
truncate your second and miliseconds
 
I know I should group but I don't know how and which functions use
 
43
Q: Grouping into interval of 5 minutes within a time range

skyI have some difficulties with mySQL commands that I want to do. SELECT a.timestamp, name, count(b.name) FROM time a, id b WHERE a.user = b.user AND a.id = b.id AND b.name = 'John' AND a.timestamp BETWEEN '2010-11-16 10:30:00' AND '2010-11-16 11:00:00' GROUP BY a.timestamp This is my ...

 
9:57 AM
thanks I test it :-)
 
@tHiNk_OuT_oF_bOx do you have a screenshot you can share?
 
@AndyK
System.Data.SqlClient.SqlException (0x80131904): An expression of non-boolean type specified in a context where a condition is expected, near 'MATCHES'.
An expression of non-boolean type specified in a context where a condition is expected, near 'MATCHES'.
An expression of non-boolean type specified in a context where a condition is expected, near 'MATCHES'.


at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasCo
 
what is your query?
 
one SP
in that Sp I am using some logic to update the record
based on one condition
Thats too using IF EXISTS()
 
have you try your query, without putting it into sp?
 
10:58 AM
morning all
rather than putting up another question about if else statements I thought i'd just pop it here
i'm iterating through a table with a semi complex set of joins, when the row returns a zero or a null I want to run a select statement to populate that row
example:
Select t1.column1 from table1 t1
IF t1.column1 = 0 OR IF ISNULL(t1.column1)
(SELECT t2.column1 FROM table2 t2 WHERE t2.PrimaryID = t1.secondarytablePrimaryID)
so I would end up with the amount of rows available in table1 and when column1 in table 1 is blank or null it will search for the matching row in table 2 and output column one from that
my unique key as you can probably tell is called PrimaryID and I do keep a reference to the equivalent PrimaryID in table2 within table1 (shown in the example as secondaryPrimaryID
this is MS server 2015 btw
 
11:20 AM
Morning guys
@elboffor this is what?
you serious?
can I get a screenshot of that, cause I didn't think a Microsoft SQL Server 2015 existed
 
2012
 
@Shaneis you're providential !
 
just double checking with the server admins, I'm not 100% tbh they have just set up the new machine which we are running (was previously on 2005)
yeah it is 2012 R2
 
11:37 AM
@AndyK I'm what?
 
aka you're the man
 
@elboffor So, why don't you just use a LEFT JOIN and then an ISNULL()
@AndyK ah cheers @AndyK, good morning to you too
 
good morning
life seems crazy
've been working my arse off this whole morning
 
I need to be able to grab the second tables data if the response is 0, not just null
but if it isn't 0 I need to mak sure it does call the second table (which may also include data) otherwise I would just left join and add them
 
NULLIF marks things as NULL if they match what you put in...
 
11:48 AM
ah cool
 
so ISNULL(NULLIF(t.column1, 0), <other table's data>)
 
thx
 
@AndyK yeah, meetings all mornign that's why I'm so late signing on
@elboffor hope it works for you
 
seems logical so should be good
just got to write this beast of a thing :/
thanks for the help :)
 
12:03 PM
hey @shan
hey @Shaneis, just checking, it does still count the null's as null and not just the 0 doesn't it?
just I seem to be getting a lot of null responces is all
 
yeah, the ISNULL is evaluated after the NULLIF
`ISNULL(NULLIF())`
 
ok thanks, it's my fault for trying too much copy and paste from the old scripts I believe.
i'll build it fresh :)
 
 
2 hours later…
2:16 PM
I am wondering if anyone is around to give me some feedback on how to do something? :)
 
2:42 PM
@CalvinSmith go for it, why not
 
3:13 PM
If I have
UPDATE t1
SET t1.DottedID = t2.DottedID, t1.Name = t2.Name, t1.Colour = t2.Colour, t1.Food = t2.Food
FROM testTo.dbo.People t1, testFrom.dbo.People t2;
why does it take the same value from t1 and put it in all the rows in t2?
 
3:24 PM
back
I feel like wasted
 
@BlueBarren because that's a cross join, you're missing a where clause or an ON clause
@AndyK what's up?
 
put the domain name online
put the website online
 
Well I don't want a where because that'll limit me to specific set of rows when I want to change them all, right?
 
yeah but how are you joining People t1 to People t2?
 
um I guess I'm not right now?
idrk
 
3:35 PM
@BlueBarren yep, you're not
hold on
You've done this
 
So I should be adding the where and compare IDs?
Because if I add WHERE t1.ID = t2.ID; 0 rows are affected and everything is still the same (like all the rows have the same value)
 
@BlueBarren if you want them to link up, if not...well then you have to give us more info
 
I'm trying to replace the data in t1 with the data from t2
I thought an update would suffice
 
is it the same table?
 
two tables with the same name
the db's have different names
so this testTo.dbo.People t1, testFrom.dbo.People t2
or I hope that's a good enough indication of the structure
 
3:48 PM
can you write it as a select, getting the old value and the new value
 
What do you mean?
The second part of your statement
 
4:05 PM
something like
select t1.DottedID, t2.DottedID, t1.Name, t2.Name, t1.Colour, t2.Colour, t1.Food, t2.Food...
can you do that first?
 
sure, do you want to see the output the statement itself?
 
It should show you what's going to happen when you turn your select into an UPDATE
yeah why not, if you're able to
 
Can I not upload a picture to the chat? You were able to
 
should be able to, there's an "upload" button beside the "send" button at the bottom
 
not for me, maybe it's a rep thing?
 
4:15 PM
@BlueBarren don't think so...should just need 20 rep...
 
i.imgur.com/zKLjPeh.png here's a link instead
I only see this orange send button, there's nothing below or around it
1 1.1 Brian Orange Pizza
2 1.2 Franz Purple Yogurt
3 2.1 Lee Red Sub
4 2.2 Danny Blue Mash
this is testFrom.dbo.People
and this is testTo.dbo.People
9 1.1 Brian Orange Pizza
10 1.1 Brian Orange Pizza
11 1.1 Brian Orange Pizza
12 1.1 Brian Orange Pizza
the columns on both go ID, DottedID, Name, Colour, Food
 
well there's a hack but..it's a hack
run it again with this
WHERE t1.ID = t2.ID + 8
 
why +8?
 
like i said, it's a hack but your t2.IDs are 1, 2, 3, 4 and your t1.IDs are 9, 10, 11, 12
so to join them on a 1:1 relationship
add 8 to them
 
hmmm I guess that works in this scenario but that won't do me much good for what I really wanted to do
I was testing stuff hence testFrom and testTo were the db names
 
4:21 PM
yep, hence why it's a hack
don't know more without me guessing the data
 
I wish I can help but the weekend has been a long one
 
don't worry about it @AndyK
 
cheers mate
 
what sucks is that with what I want to do is that it can't be 1:1 because there isn't the same number of records
we'll say a 150:200 ratio
 
hmmm...so then the question is do you want to update all of them or just the ones that match...
also no worries @AndyK
 
4:25 PM
I was just looking into this because I didn't want to do something manually but I'd probably get it done faster at this point. I essentially want to overwrite the contents of database2.table with database1.table's values
 
a straight up overwrite?
 
well not all my columns, just some
I don't know if you'd call that straight up
 
@BlueBarren Yes
 
so sure a straight up overwrite then
well a link will suffice then @Sami
gotta work with what I got xD
that #49replyfe
Bye?
oh thanks
thanks again
 
Don't mind Sami, @BlueBarren
 
4:30 PM
then how about just an DELETE then a INSERT INTO ... SELECT <columns>
 
@AndyK he seems alright
@Shaneis I was trying to do that but my problem there was that... oh I closed that query window xD
I was trying to delete then insert but I had some issues then wrote it off
 
guys, I'm off
see ya tomo
 
bye bye @AndyK
 
@BlueBarren ah he's fine, he thinks we're angry at him for some reason
see y a@A
@BlueBarren well I like that option :)
let me know and I'll see if I cna help
 
4:33 PM
I shall proceed to try that option again, I shall around incase things go wrong
 
cool, I'll be here for another hour anyway
 
4:44 PM
can you not delete the values for an entire column?
 
You have to delete a whole row man, not a column
what DB are you using btw
 
but I don't want to delete rows, there's still some stuff I want to keep
I'm still using my test DBs
 
yeah but is that mysql, SQL server, Postgres?
 
oh mysql
 
SELECT * FROM TestTo.dbo.People AS toP full outer join TestFrom.dbo.People AS fromP on toP.Name = FromP.Name
what does that give you?
 
4:52 PM
it doesn't like the first toP
 
huh change FULL OUTER to Left JOIN
 
it's because of incorrect syntax
that it doesn't like toP
 
hmmm I don't know MySQL syntax
can you left join TestFrom to TestTo?
on the names?
 
yeah I just don't remember how
I haven't done sql for a while
hence I needed the help xD
 
select * from testFrom.dbo.people to_p left join testTo.dbo.People from_p on to_p.name = from_p.name
 
5:02 PM
 
cool cool so is that okay to turn into an update?
 
Not sure, would it only work on a 1:1?
so I added another entry to testFrom and with that join I get NULL NULL NULL NULL NULL on the testTo side
so how do I take this into my update? is it my where clause?
 
yeah that would work 1:1
you would have to insert the rest
so you could update where IS NOT NULL
and insert WHERE IS NULL
 
this is getting kind of complicated
sigh
 
@BlueBarren soz
 
5:12 PM
I'm working on it okay? geez
so this is what I have
 
@BlueBarren you wanna hurry up a small bit...
 
and it doesn't like the WHERE syntax
I guess I have to on instead of where my bad
thought I had to adapt it more
 
it's not really a "my bad" when you figure it out yourself though
 
so true
so it said 5 rows affect but I can only see 4
so yeah insert then
so how many more times can I say "so"?
 
I have you at 7 since I started counting :D
 
5:16 PM
I only count 5...
 
I started counting after your last pic
 
should the IDs on testTo now that I've replaced the data in there be 9-12 instead of 1-4?
well we never set ground rules on when we'd start counting
 
Only if you have updated them, if you haven't done set id = id then they shouldn't be affected
also true but we can't start now, cause you're aware of it
 
I will never say that word that should not be named ever again
you can do those sudo if in SQL, yeah?
 
@BlueBarren My Little Pony?
 
5:20 PM
cases I think
 
sudo if? you mean CASE statements?
yeah
 
what about my little pony?
 
that which should not be named
 
I said word, not three ;)
 
apologies MyLittlePony
 
5:21 PM
that's not a word
classified as gibberish
 
It's 1 word!!!
Gibberish is my first language to be honest
 
if I can't find it in the dictionary it's not a word. my first language may be dyslexia, never been tested though I've just been accused of having it
what am I checking is null?
for my cases
 
the left join is going to return nulls if there is no link
so if there is no link then you'll need to insert
 
I can't do a case for that can I? I thought it had to be a column
 
I don' think you can do a case for insert/update...think you have to do 2 statement
UPDATE...
where <column> IS NOT NULL
and then
INSERT
WHERE <column> IS NULL
 
5:25 PM
if that's the case then what do I check is null or not?
 
I would check on that you're joining the tables on
so if testTo.Name is null that means it is not linked and you'll have to insert it
 
I also have to think about this for my actual scenario, it'll probably be DottedID. I shared that column from my real data with my dumby stuff
 
@BlueBarren fair enough, you're the boss there. You'll have to figure out what works best
 
I'm always the boss
not just here
or there
 
@BlueBarren explains the profile pic anyway
 
5:30 PM
I'm the Big Boss
 
@BlueBarren well "Big Boss" I'm leaving in 10 so any questions, you best ask 'em
Not sure if I'll be on later
 
if that's the case then I'll say idk how to insert
 
bahahahahahaha
okay okay
 
INSERT INTO testTo.dbo.People (to_p.DottedID, to_p.Name, to_p.Colour, to_p.Food)
VALUES (from_p.DottedID, from_p.Name, from_p.Colour, from_p.Food)
FROM testFrom.dbo.people to_p left join testTo.dbo.People from_p on to_p.Name = from_p.Name
WHERE from_p.Name IS NULL;
like no?
it doesn't like my values
 
change the values to a SELECT
and get rid of the brackets
nice catch apart from that
so...
INSERT INTO testTo.dbo.People (to_p.DottedID, to_p.Name, to_p.Colour, to_p.Food)
SELECT from_p.DottedID, from_p.Name, from_p.Colour, from_p.Food...
 
5:33 PM
FROM testFrom.dbo.people to_p left join testTo.dbo.People from_p on to_p.Name = from_p.Name
WHERE from_p.Name IS NULL;
those two things together are the entire statement then, yeah?
 
yeah..that's the rest...
 
ah okay
thank you @Shaneis
 
no worries boss
 
ah row 5 was inserted with null :/
 
hmmm...is it the case that there is more rows in to_p than there is in from_p?
 
5:35 PM
more in from_p because I added another to test some things
 
@BlueBarren hmmm damn that's awkward
if you want, throw some sample data up and I'll build tables and take a look later
I gotta go now though
see ya man
 
bye bye
and thank you
 
 
1 hour later…
6:57 PM
    Hi, if i have a query with common table expression

    WITH my_cte
    ( ID, FirstName, LastName)
    AS
    (Select  ID, FirstName, LastName FROM Employees)

    Select * FROM my_cte
    OFFSET 0 ROWS FETCH NEXT 15 ROWS ONLY
how does it work? it will select all Employees into CTE and than apply offset fetch?
or cte will be executed together with offset fetch and only 15 rows will be selected
at all
 

« first day (1662 days earlier)      last day (2656 days later) »