« first day (2376 days earlier)      last day (1942 days later) » 

12:02 AM
Hahaha
But diff timezone
Too late night @Sami.. :D
 
12:34 AM
Alright @dwir182 it's 01:34
Good night :)
 
Good night man..
:)
 
 
4 hours later…
4:25 AM
I'm having a little trouble thinking about how I'm going to query some data. I'm using PostgreSQL

I need to feed a view that has a list of ports a ship is visiting.

Within that view, it also has to show if there is an intersecting ship or an intersecting user (e.g a user or ship that will be in that same place and have some time overlap with the current user)

Anyone that can help me think this through?
 
4:37 AM
I was thinking of running three separate queries and mashing them together server side but I'm not sure if there is something in SQL I could use.
 
5:25 AM
@MikeJenkins use dbfiddle.uk to build your sample data
 
Thanks, I'll take a look.
 
Nope.. I mean you made your scenario in there
I will help you make query
what version do you use?
postgresql
 
I'll check.
I'm on postgresql 10.4
I'll be back once I've figured out how to use dbfiddle. :P
Working on seeding some data.
 
5:59 AM
@dwir182 I've put some seed data in. https://dbfiddle.uk/?rdbms=postgres_10&fiddle=bc4ec0213cbccb5245b0ad4760d3e426

User #1 and User #2 have 'postings' on different ships (postings being a time that they are contracted to be on the ship)

Both ships make a call at port 451 on the 9th of November.
The idea is that user 1 has visibility that they will be intersecting user 2.
and vice-versa, depending on the current user.
Let me know if any questions or any more effort needs to be made on my part.
 
What do you want achieve?
Show your expected output in your sample data
 
Okay
 
+----------------------------------+---------+------------------------+----------------+
|               Col1               |  Col2   |          Col3          | Numeric Column |
+----------------------------------+---------+------------------------+----------------+
| Value 1                          | Value 2 | 123                    |           10.0 |
| Separate                         | cols    | with a tab or 4 spaces |       -2,027.1 |
| This is a row with only one cell |         |                        |                |
Make like that use that link
 
Working on it. :)
 
Wait.. You don't have foreign key?
 
6:10 AM
I've simplified it a bit.
+----------------------+---------------------+---------------------+---------------+---------------+
| name | arrive_date | depart_date | users_in_port | ships_in_port |
+----------------------+---------------------+---------------------+---------------+---------------+
| Sydney, Australia | 2018-11-05 06:00:00 | 2018-11-05 18:00:00 | | |
| Dunedin, New Zealand | 2018-11-09 08:00:00 | 2018-11-09 18:00:00 | 1,2 | 186 |
```

+----------------------+---------------------+---------------------+---------------+---------------+
| name | arrive_date | depart_date | users_in_port | ships_in_port |
+----------------------+---------------------+---------------------+---------------+---------------+
| Sydney, Australia | 2018-11-05 06:00:00 | 2018-11-05 18:00:00 | | |
| Dunedin, New Zealand | 2018-11-09 08:00:00 | 2018-11-09 18:00:00 | 1,2 | 186 |
Ergh how do I markdown?
+----------------------+---------------------+---------------------+---------------+---------------+
|         name         |     arrive_date     |     depart_date     | users_in_port | ships_in_port |
+----------------------+---------------------+---------------------+---------------+---------------+
| Sydney, Australia    | 2018-11-05 06:00:00 | 2018-11-05 18:00:00 |               |               |
| Dunedin, New Zealand | 2018-11-09 08:00:00 | 2018-11-09 18:00:00 |           1,2 |           186 |
So giving me back the ID's of the users_in_port and ships_in_port is about the only way I can think of getting it back in table format.
Otherwise I'd pull back and array in JSON format with the actual data.
 
What's behind users_in_port and ships_in_port?
 
If a user is assigned to a ship by a posting, and their ship visits the same port.
So really, we first find which ships we're in port with, and then find which users we're in port with.
 
6:27 AM
morning guys
 
+----------------------+---------------------+---------------------+---------------+---------------+
|         name         |     arrive_date     |     depart_date     | users_in_port | ships_in_port |
+----------------------+---------------------+---------------------+---------------+---------------+
| Sydney, Australia    | 2018-11-05 06:00:00 | 2018-11-05 18:00:00 |               |               |
| Dunedin, New Zealand | 2018-11-09 08:00:00 | 2018-11-09 18:00:00 |           1,2 |       186,185 |
Hi Andy.
Above I've added my own ship to the ships_in_port for clarity, however in the query we might exclude our own user/ship
 
i don't get it from your result..
 
I think that's right, but the second aggregation should be ship not port.
I am so thankful for your time.
I'm not sure if I can do a nested query on the aggregate to get the actual data back.
as in, users in port could be JSON
[{"id", 1, "user": "mike"},{"id", 2, "user": "mel"}]
Is that doable or am I just asking too much?
 
6:50 AM
Never tried it.. But you can use to_json
I can't help you now.. I am on busy and many works to do.. Good luck.. :)
 
Your help has been awesome already, thank you. :)
 
NP.. :)
 
7:23 AM
Morning!
Can anyone please explain this?
 
Morning..
What the.. Hahaha
 
But all the the other columns go to my REGISTRATIONS table? da hell?
The question get an UP although is not clear at all
 
7:43 AM
?
 
Sorry I just realised I messed it up and the data wasn't actually what I was expecting.
I should go to be.
bed
 
you always have the same users and ship in port
 
Yeah exactly.
Here is the version that works.
 
oh you changed away from writing names
 
I want to actually extract user data and ship data in those columns but I can't figure it out.
I don't know if it's worth making the db do this work for me anyway.
 
7:51 AM
mornign
@WhatsThePoint i just saw that screenshot u linked, and damn that code was disgusting
 
It's not about worth or not.. When it comes to learn always worth.. But the question is.. Is that your passion?
Easy boy.. Haha
 
Well I guess I choose between dealing with this inside or outside of sql.
I think it can be done in sql, but it may actually be costly.
 
@Tomm Morning kid 0/
 
o/
 
@Tomm If kid is annoying I'll stop it, just say :)
 
7:58 AM
its fine
i dont bother that much about what people say to me ;p
 
:D
 
Hey old man.. O/
 
@Tomm now i need to scroll back to remind myself :D
 
:D
@WhatsThePoint prntscr.com/lj7n4p
 
8:13 AM
hey guys
catch u later
 
@Tomm oh yeah that was funny :D
cya @AndyK
 
@AndyK good luck man..
 
seems the question is still open even though my flag was helpful stackoverflow.com/questions/53340697/…
 
8:31 AM
morning
 
morning andrew
 
hey andrew
 
9:16 AM
Morning all
 
late morning @Shaneis ;p
 
hes probably already gone for his coffee
 
9:35 AM
haha
 
... @WhatsThePoint YOU DON'T KNOW ME!!!
.... but yes, yes I was
 
@Shaneis @WhatsThePoint Morning!
 
morning @Sami
o/ @Tomm @WhatsThePoint
 
@Shaneis What's wrong with War?
 
9:44 AM
He's fighting buses
 
lol
 
morning @Sami @Shaneis
yeah war hasnt been on for a while, if i actually used discord id probably be able to speak to him
 
@WhatsThePoint Please if you catch him, tell that Sami says "Get in here you old blue ball"
 
i think @Tomm uses the discord chat
 
war said : @★ Marshal - Tom yeh i forgot my facebook password once ... now it's being a dick
fb support won't help so i'm working on a hack to get in
 
9:51 AM
lol
 
does password reset not work?
 
Nah, sometimes FB password reset won't work, and they ask you to send them your identity (which is no one will do) so you have the choice hack it or leave it
 
simple solution
Don't forget your password
 
10:08 AM
Create your own app to store such things
 
10:38 AM
Surely some easy points for the day : stackoverflow.com/questions/53372649/…
 
War
sup
@Sami i has returned
facebook ... hacked!
wasn't too bad either ... only took me a day
after the code was written anyway
....
so uh ... what i miss ?
 
@War \0/ welcome again bb
@Andrew Don't you answer it?
 
10:57 AM
I did but getting a duplicate problem, so deleted my answer while I figure it out
problem is a row full joins itself
well, it creates two rows, one for each side of the full join
 
Alright @Andrew here is an easy points stackoverflow.com/q/53372467/6426692
 
figured out my mistake, missed a +1
 
@Sami nice answer..
@War hey..
 
on the company amazon account :P
 
War
11:45 AM
i cant win
i took the efficient root and only computed effective permissions for effected rows
kept getting told "its not working" so i triggered a full re-compute which i'm told does make it work (despite it calling the same logic)today i did a deploy ... they've triggered a full recompute in production and now they are complaining it's taking a long time
well ... no shit
i wanted to do it the efficient way and was told "it doesn't work" ...
 
Production vs Development... i know the feeling :D
 
War
12:21 PM
so the long and short of it ... I have physically separated the front end and the back end ... the net result is that if the front end wants to do anyhting that involves a DB it has to make an API call to an OData endpoint that in turn decides on the actual SQL that gets executed
I was asked over the weekend to look at getting the new version of the front end in to production
today one of my team made an api call that caused all these permissions recomputes in the db layer (which is time consuming)
then i get told "omfg you deployed the front end now everything is broke"
What's actually going on is that the back end is recomputing all permissions for every user on every entity in the db, the net result of creating a new web app (new apps in my web stack are defined as rows of data in the db)
so how is that even remotely related to what i did ?
 
 
War
Marathi (English: ; मराठी Marāṭhī; Marathi: [məˈɾaʈʰi] (listen)) is an Indo-Aryan language spoken predominantly by around 83 million Marathi people of Maharashtra, India. It is the official language and co-official language in the Maharashtra and Goa states of Western India, respectively, and is one of the 22 scheduled languages of India. There were 83 million speakers in 2011; Marathi ranks 19th in the list of most spoken languages in the world. Marathi has the third largest number of native speakers in India, after Hindi and Bengali. Marathi has some of the oldest literature of all modern Indian...
 
Oh, but that's not a marathi column lol
 
War
I think he means "columns containing data in marathi"
suggest an edit
 
12:37 PM
Still the question need to be closed as TB/Unclear
 
War
its a new user dude
suggest an edit ... don't be elitest
that said ... it's kind aunclear for other reasons
He talks about converting names ... surely names can't be converted
my name is still Paul no matter what language it's presented in
 
But, what he want to do there? translate the strings already stored in marathi to english or he has an issue to store marathi in that column?
 
War
although some languages don't rely on our alphabet so there's some more symbolic stuff that might require conversion
i don't know enough about marathi to say either way
but unicode chars will cover marathi i would think
that's kinda the point to unicode
 
I'll wait for some time, then I'll report it if the OP does not respond
 
War
your edit clears it up i think
i've approved it
needs 1 more up vote though because i don't have mod rights yet
 
12:49 PM
@War Edit it again
 
War
seems fine how it is
i have nothing new to add
 
1:02 PM
Alright, he get an answer
but that is ugly
War = War
but the translation maybe wrong for the most of names
I don't think is a good idea to use Google/Microsoft translator for this
 
1:17 PM
Duplicate.. Don't use self join @Sami
 
1:59 PM
hi
why this is wrong
declare @count int;

@count = select count(*) from student;
 
declare @count int;

set @count = select count(*) from student;
 
2:12 PM
you need paranthesis
declare @count int = (select count(*) from student)
 
yeah that too ^^
 
or do select @count = count(*) from student;
not sure if I have a preference amongst those options
inline to the select is more flexible for setting multiple values - thats about it, but its a bit less obvious in some ways that it is setting
 
2:26 PM
declare @count int = (select count(*) from student);
@Breathing ^
@dwir182 ?????
 
just got my first good answer badge
 
gotcha thanks xD
 
War
@WhatsThePoint link to it ?
 
25
A: Python 3.6 install win32api?

WhatsThePointThere is no version of specific version ofwin32api. You have to get the pywin32module which currently cannot be installed via pip. It is only available from this link at the moment. https://sourceforge.net/projects/pywin32/files/pywin32/Build%20220/ The install does not take long and it pretty...

 
War
have another up vote on me
 
2:40 PM
@War aww <3
thanks
 
3:00 PM
@Sami what you remove are same statement right
So don't use self join..
@WhatsThePoint congrats for 2.1k.. :D
 
1 step closer to 10k :D
 
the rep tends to accelerate - old answers pick up points, so the more answers you have out there, the more random rep gains you get
 
58 answers for me, dont do much answering, i mainly review
 
3:20 PM
@WhatsThePoint Sorry, already UV it
 
@Sami ty anyway <3
 
3:35 PM
dwir182 was able to help me a little with this sql query last night.

I've been messing with a bit to see if I can:

1. aggregate users_in_port and ships_in_port to appear as JSON
2. make results of the above mentioned unique (no duplicates)

I'm also really interested in hearing efficiency arguments vs dealing with some of these problems in application logic.

Here is the fiddle, working as best I've been able to get it.

https://dbfiddle.uk/?rdbms=postgres_10&fiddle=ba2f3b17f3a245aa2ac427cfb6777cee
+---------------------------------+---------------------+---------------------+-------------------------------------------------------------+-----------------------------------------------------------------------------+
|              name               |     arrive_date     |     depart_date     |                        users_in_port                        |                                ships_in_port                                |
+---------------------------------+---------------------+---------------------+-------------------------------------------------------------+----------------
and above is my desired result
Although let me try and format that a bit better.
Screen shot if it text doesn't play nice for you (works for me, just gotta zoom out a lot): imgur.com/a/Ox9RyBP
 
 
1 hour later…
5:05 PM
@Sami lmaoooo
 
;)
 
!!andy2
 
@AndyK LOL
 
5:35 PM
I'm confused. Is this the wrong place to ask a question? If so, where should I ask it?

Or if it's that my question is so stupid that it shouldn't be asked, tell me why?
 
 
2 hours later…
7:26 PM
@MikeJenkins you can ask a question but the answer is not compulsory.
as you may have noticed, we all work, when maintaining a presence here
hence, the delay
it is not ill will , just often drop your question and we will ask if we have the time
in case, we don't have time like today, the best thing to do is ask a question on the main site
 
@AndyK My issue isn't with time. I was a bit confused by the comments below my question. E.G. lmaoooo
 
@MikeJenkins soz
I was checking the room, hence the comments
what do you want to do with your query?
 
I'm not even sure if I need to/should go further with it.
 
@MikeJenkins ok
 
However as you see i have an itinerary and a need to query for new information within each result.
I figure there is a pure SQL solution, which I don't have a lot of experience with.
Or I could build a different query and map through it in application logic.
My conundrum is almost completely "How do get this nested data?" and when should I do it.
 
7:34 PM
you can use CTE
each CTE will act as a subquery or a temp table if you like
and then, you can use that temp table to cascade it into another temp table until you have the correct results
 
Okay. I'll have to look into that.
 
lol
the OP just accept the wrong answer - stackoverflow.com/q/53380978/6426692
@AndyK That ^ happen a lot
 
 
1 hour later…
9:04 PM
0
A: How to write SQL Query to remove a given set of special characters from a selected column?

SamiDo you want something like CREATE TABLE T( ID INT IDENTITY(1,1), Value VARCHAR(45) ); INSERT INTO T(Value) VALUES ('.A*B$C@'), ('D#E$,F'), ('.G,H*I@$'); DECLARE @Chars VARCHAR(45) = '@$.,*#'; SELECT *, REPLACE(TRANSLATE(Value, @Chars, REPLICATE(' ', LEN(@Chars))), ' ', '') Result FROM T;...

if anyone face similar problem
 
9:17 PM
I answer it after the question marked as a duplicate
 
10:07 PM
@Sami really neat..
 
^_^
 
Now you should sleep!!
Btw good morning..
:D
 
lol
@Shaneis ^ in case you work with such cases
@dwir182 Did you notice that I answer it after the question marked as a duplicate?
 
10:31 PM
Mooorning @dwir182, Milk? Coffee? Tea??
 
10:50 PM
@Sami yes.. Haha
Milk of course..
:p
 
:D
 
11:05 PM
@dwir182 Do you know a good TextToDll online tool?
like sqlfiddle texttodll
sometimes the website is down and can't use it
thus I need another option
 
nah
there is no SQL Server there
 
Oh i forgot your type..
Haha.. I just know sqlfidlle
Who have texttoddl
With sql server
@Sami
 
11:38 PM
Hmm
00:38!!
my eyes I can't even see well
bye cya tomo
 

« first day (2376 days earlier)      last day (1942 days later) »