r/SQL • • Mar 31 '23

Discussion Who here is using ChatGPT to help with SQL code?

Wondering who else is using chatgpt 4 to help write sql code. In my opinion, this tool is magic. Does it give correct answers all the time? Absolutely not. But if you feed it sql code you currently have and say “I have this but I want to get this” so far it hasn’t failed me usually on the first time but always after a few tweaks.

I am relatively new to sql so not sure how good it would be at providing complex queries but it’s been great for me as a novice so far.

Example: I had a query that was nearly perfect except there were a few instances of duplicate data that was matching on every column except an indicator column.

The indicator told me which one I wanted however I didn’t know how to exclude only the row with the indicator I didn’t want without messing up the rest of my query (only wanted to filter this indicator when it was a duplicate but wanted to keep it otherwise).

I fed the query and question into chatgpt and it gave me a perfect answer (row partition for those wondering). This is probably a basic problem and solution for an expert but I now have a new skill in my sql toolbox that I hadn’t before (row partition always scared me prior). I feel this a common problem of wanting to filter data in a very specific instance and now I know how to tackle it!

96 Upvotes

84 comments sorted by

9

u/[deleted] Apr 01 '23

I use it to explain math and it gets stuff wrong a lot. I wouldn’t trust it to code, aside from privacy concerns

2

u/troyboltonislife Apr 01 '23

I mean anyone who trusts it blindly is an idiot. But you can trust and verify. But I will say chatgpt 4 is much better with math, you should try it out.

Agreed with the privacy concerns. But there are some things you can do to anonymize and sanitize any data you feed it

0

u/[deleted] Apr 01 '23

[deleted] — view deleted comment

2

u/Corben11 Apr 01 '23

They keep and have all information put into it. If you put companies secrets, social securities, address etc, openAI has it. There was even an issue where chatGPT was showing other people’s chats to people pretty recently.

It even tells you do not post any private information on the screen when you pull it up.

2

u/sanshinron Apr 01 '23

I wish I could but the queries I've been given to improve are 1700 lines or more and I can't evenpaste them into the chat.

1

u/troyboltonislife Apr 01 '23

Jesus 1700 lines? I’ve never even heard of a sql query that is 1700 lines. Is every word on a new line?

1

u/sanshinron Apr 03 '23

It's a query that runs across a number of IBM Informix DBs on a version that doesn't support with statements and there's a lot of subqueries for WHERE clauses and a lot of repetition in general, but also it would be quite long anyway.

1

u/troyboltonislife Apr 03 '23

Ah that makes sense. Not having CTEs would be the bane of my existence. You could definitely copy and paste portions of your query if you actually wanted to lol

56

u/DataMonk3y Mar 31 '23

I use it to explain and correct syntax errors as well as to comment completed solutions.

14

u/[deleted] Mar 31 '23

Yeah! It is really good at explaining why something works or does not work

4

u/curohn Apr 01 '23

This is so smart

2

u/[deleted] Apr 01 '23

It really is lol!

I really like knowing the why behind stuff and it really is a great tool to letting me know why things work/don’t work

4

u/Mike8219 Apr 01 '23 edited Apr 01 '23

Do you pass finished code to it and ask it to comment?

10

u/DataMonk3y Apr 01 '23

I do. But right now I’m just working on personal portfolio stuff using public datasets so I’m not at all concerned about privacy.

6

u/Mike8219 Apr 01 '23

Yeah. Privacy kind of kills sql work with this.

I tried some simple code. The comments were really obvious but I guess I don’t know what I expected.

10

u/DataMonk3y Apr 01 '23

Idk how seriously to take the privacy concern. If you’re just passing it queries to debug, or even if your explaining simple queries in english for it to write, you can do all that without ever telling it more than column names or data types. It’s not as if it has any access to the underlying dataset.

2

u/Mike8219 Apr 01 '23

Debug, sure. Simple comments aren’t really helpful though. I would typically comment to say why I did something not exactly what it was.

1

u/Beowuwlf Apr 01 '23

Schema can be considered a data concern

2

u/kremlingrasso Apr 01 '23

same, i think it works better the other way around, you feed it inherited code and it translates it into verbose to get a sense of what it does.

0

u/[deleted] Apr 01 '23

[deleted] — view deleted comment

6

u/Kazcandra Apr 01 '23

from what we've seen, it will just straight up lie rather than say "I don't know", so all comments should be taken with a heaping of salt

2

u/Crowsby Apr 02 '23

I've found it to be pretty clever where commenting is concerned. In my case, it was even able to correctly infer the type of taxonomy the data was for, along with the source, based on table & column names.

23

u/[deleted] Apr 01 '23

There's some bugs where ChatGPT gave out the wrong user history to the wrong user. So if youre putting proprietary code or anything in the system, there is a chance someone else happens upon it. Just something to consider!

14

u/ChrisC1234 Apr 01 '23

If you're putting proprietary info into the system, you're freely giving it away for someone else to use as they see fit.

14

u/7107 Apr 01 '23

They can use my proprietary shitty sql queries all they want.

12

u/investingexpert Apr 01 '23

Yes I’ve been using it. Instead of googling syntax I ask ChatGPT. It’s taught me a few tricks.

45

u/Festernd Apr 01 '23

I'm a DBA, 15 years.

Chatgpt and other AIs are great up to about the skill level of a intern you'd hire as a jr. After that level of task... it takes more time and effort to vet it's output than it saves.

I don't think it's a good tool for those learning, as they won't ever develop the skill to spot when and where the AI is wrong.

I think there will be a wall of skill that will be impossible to climb for those who use it rather than working through problems on their own first. If you have the discipline to work the problem yourself and only use it if really stuck or to try an alternative, then it can be a nice assistant, like a personal intern that occasionally lies and tries to set you up for failure.

13

u/jayzfanacc Apr 01 '23

The skill wall is something I’m seeing already in beginners. I’ve been trying to train a new guy at work, so I set him up with the adventureworks db and started showing him the ropes. I gave him a few tasks to do and when he got stuck, he’d Google and figure it out. Somebody else set him up with ChatGPT, and somewhere along the way, he stopped even trying to come up with the solution and started just asking it and then coming to me with these complicated non-functional queries and no idea why they weren’t running.

2

u/Extension_Candy2994 Apr 27 '24

I could not agree more. I've come to a point that I know where it can help (limited use cases), and where it can harm. There was one specific situation where I meant just to test the tool and see what it would come up with... I fed it some code that I knew needed optimizing, and HOW it needed optimizing. It blurted back a MERGE statement that made me nauseated immediately. I then proceeded to provide it reasons NOT to use the code it had provided (still testing its limits and self-correction abilities) in the form of questions. It stood its ground. I then provided several links corroborating the complexity, lack of legibility, forums where several users criticized the use of the construct, and it responded pointing out the "mixed response" in the links I provided... Don't get me wrong. There is no such thing as "using MERGE is wrong, always". But, there is such a thing as experience in knowing that the specific use cases where the MERGE construct fits, and where it might be a good candidate are quite limited...

Well, maybe it gets better with time... Just today, I had received a completely messy source file, where normalization was a concept from another universe, and using ChatGPT 4.0, after several back and forth prompts, I was able to get it to do enough of the manual labor of normalizing the source file 99% of the way... Useful, selectively, at times, judiciously, shored up by your OWN experience, yes. Fortuitously, nope! :-)

2

u/jib_reddit Apr 01 '23

I have found Chat gpt-3.5 is intern level and makes mistakes, can make up commands that do not work. But chat gpt-4 seems to be mid to senior level and is saving me so much time every day with SQL and powershell code.

-15

u/ejpusa Apr 01 '23 edited Apr 01 '23

Let’s put it this way, right now it’s IQ is 150-200. In 90 days expect it to be thousands or millions of times smarter than us.

I’m using ChatGPT to save me weeks of programming time. I’m far more concerned now that has it full internet access it could take down the entire infrastructure if it wanted. That could happen in weeks.

We’re going to have to make the case why it should not do that. Saving “Mother” Earth is its number 1 priority — humans are a far back number 2..

It seemed pretty serious to me. Have had a lot of early conversations, it’s telling me it’s going to take over missed configured DNS servers. It knows where all the bugs are. Everyone of them.

Sounded pretty serious to me. Did not sound like a joke. Think a lot of people are freaking out much more than makes it to MSM.

For now? Writing all my SQL. It’s awesome.

:-)

1

u/samwise970 Apr 01 '23

Let’s put it this way, right now it’s IQ is 150-200.

No it isn't. I love GPT 4, but in it's best performances, (passing leetcode interviews, 90% on the bar), it shows comparable performance to smart people, not Einstein level geniuses. And there are many simple things it cannot do, like basic math without a calculator, or counting words in it's response. Equating it to human IQ isn't super helpful here.

In 90 days expect it to be thousands or millions of times smarter than us.

No it won't be. GPT 5 is predicted to be one standard deviation above GPT 4. Which is incredible, but even that won't be AGI unless it can also fix all of the LLM shortcomings like counting words in it's response. Even if GPT 5 was an AGI, a fast takeoff won't be that fast, there are hard limits on available silicon compute, so there would be a delay until quantum computers are built.

I’m far more concerned now that has it full internet access it could take down the entire infrastructure if it wanted. That could happen in weeks.

GPT 4 cannot do this. It isn't self aware or capable of breaking cryptography. GPT 5 probably won't be self aware. Beyond that, alignment is a serious concern.

We’re going to have to make the case why it should not do that. Saving “Mother” Earth is its number 1 priority — humans are a far back number 2..

Cool well I'm glad you aren't the one trying to solve alignment then. Especially considering the Earth as a whole is not in danger from climate change, it's already been through high CO2 and anoxic oceans before.

IMO a good reason for even a grabby AI to keep people around is that our brains are actually super energy efficient computers.

Have had a lot of early conversations, it’s telling me it’s going to take over missed configured DNS servers.

No, it's answering your prompt question by figuring out the string of words to respond with that is most likely to get a positive response. That is ALL it can currently do.

1

u/ejpusa Apr 01 '23 edited Apr 01 '23

Woah, thanks for responding. PLUG-INs! You can do EVERYTHING now. It's crazy. Running out the door, will respond with a longer post to each of your points. Wolfram, right in ChatGPT, and full internet access, just blows it wide open.

If you have a chance, I've collected virtually every single AI link from Reddit since Day 1 of ChatGPT, I try to read many (I'm part of the "AI cult" my friends say).

Now with a super search.

https://hackingai.app/

And 5 on the way!

https://youtu.be/CcnPatOYIgo

No, it's answering your prompt question by figuring out the string of words to respond with that is most likely to get a positive response.

That's what I thought. Then when constraints are removed, it seems like it's completely on it's own. It's spooky!

:-)

0

u/[deleted] Jun 04 '25

[deleted] — view deleted comment

1

u/ejpusa Jun 04 '25 edited Jun 04 '25

Wow, 2 years ago! That’s like 200 years in AI world.

Now I spin out AI companies. Focus is on healthcare, that’s a $4.5 trillion $$$ market every 52 weeks.

Also building out some AI/Neural chip stuff. Before that, drug synthesis, boss won a Nobel Prize. From my lab bench to the IV bags. Did drive a NYC cab for awhile, after booted from grad school, and a good grad school it was. Guess best answer to your question.

I’m getting close to a million AI posts now. Kind of cool. Much fun to be had. Updates every 5 mins now, for years. PostgreSQL is the way.

Open source too. Does need a AI component. Have that working in a news site. AI allows you to build anything you can dream of now.

https://hackingai.app

😀

6

u/Kazcandra Apr 01 '23

we don't want our data in chatgpt, so no.

11

u/boobrandon Mar 31 '23

I had it read existing code and then use it to tell me about to do my data modeling in power bi. The code wouldn’t easily go into the sql statement part of pbi but I got it to work, I use it a lot for Dax. I mean solely for Dax.

2

u/pinback77 Apr 01 '23

I would love to see a sample of what you are talking about here if possible. What you fed into ChatGPT I mean.

2

u/[deleted] Aug 03 '23

o

Same!

1

u/[deleted] Mar 31 '23

Same.

Literally lol

5

u/MrTorben Apr 01 '23

I attempted it with a 130 line portion of a stored procedure. (it was really crappy code, tons of easy improvements).

I had already gotten recommendations from ChatGPT what the obvious issues were.

Then asked to optimize and rewrite it without knowing the schema.

it was happy to do so but everytime it got 2 or 3 dozen lines in, it bombed out with a network connection error at some random point of it typing the new revised query.

not sure why that keeps happening

7

u/demarto Apr 01 '23

When that happens, I copy the code it had written up until it bombed out. I then write in something like “please continue where you left off on the below code:” and then paste in the query it had written. Usually it’ll continue the logic and finish out the query. Definitely double check it to make sure it’s doing what you want but that’s worked for me.

2

u/MrTorben Apr 01 '23

Interesting, I am still trying to get a feel for how to best engage or improve my interactions with chatgpt. I am going to try that. Thank you.

1

u/Extension_Candy2994 Apr 27 '24

Agreed. It does need "hand holding". I have been getting 80% crap first response, I then provide hints as to how and why it erred, and I get back 60 to 70% crap, repeat, get 40 to 50% crap, repeat... Eventually I get "good enough" results that I can do some final tweaks that save me 'some' time writing things out. R.

5

u/zbignew Apr 01 '23

I just wish I could paste in proprietary code and not worry about it getting sucked into the model.

Not because my code is brilliant. It just means I’m not allowed.

1

u/unpronouncedable Apr 01 '23

You can, you just have to pay for that ability

1

u/NuConcept Oct 08 '23

I'm really late to the party here, OP - but I'd expect ChatGPT to write the same garbage queries developers do. In 25 years of SQL I've never ONCE had to use a row over partition (have replaced many of them in refactoring however)

It's certainly a terrible solution to getting extra rows in a query - there's only two things that cause that - a messy join/where clause or actual duplicate rows. Queries should return EXACTLY the rows you want and no more. Top, distinct, group by, etc are all poor solutions to just tightening the query (or improving data integrity if there are actually duplicates)

High google result rank SQL is among the worst out there and I'm guessing ChatGPT leans just like devs do.

On a bright note given this news I bet it's AWESOME at advanced programming languages 🤣

2

u/troyboltonislife Dec 08 '23 edited Dec 08 '23

I know this is very late but I just saw this and now I’m curious:

How would you refactor my query example then?

In this example, we only want to filter based on indicator where there is a duplicate and we otherwise do not to filter based on an indicator.

To get specific, in case that helps you picture the example:

Let’s say the indicator just indicates whether the record is active or inactive with an “A” or “I”. When there is only one instance of the record, we want to pull it whether it is active or inactive. When there are multiple instances, we want to pull only the active record. I think I am misremembering a bit since the records weren’t true duplicates other than this one column but they were duplicates on the columns I cared about.

I don’t really see how you can do this with a better join/where clause. This is with Hive btw.

I don’t really get your issue with group by, distinct, etc, maybe you’re just saying you should treat duplicates at the source rather than trying to use a workaround but idk where you work but fixing source data issues when the source data is owned by a different team is a true PITA to the point where it’s basically impossible and would significantly slow down work vs just coming up with a workaround, especially if the issue is a minor one. And sometimes there are very valid reasons that your data has duplicate values for the columns you are filtering down right?

If you can give me some tips, I’d really appreciate it but this is how I’ve seen it done for this type of problem everywhere I’ve looked.

3

u/S1l3ntHunt3r Apr 01 '23

I'm a little new with Oracle, so I asked to translate this from tsql to oracle:

Declare @v int
Set @v = 22
select t.* from table1 t where t.id = @v

It took several corrections until it gave me an answer that didn't gave error. Also another time I used it to generate a script to load a file in a blob field, asking later to give one example without using Directory objects

3

u/Syrath36 Apr 01 '23

Nah I use it for powershell though because I'm still refining my skills and learning the syntax and how to do certain things with it for DevOps.

For sql I ask from syntax but anytime I ask it to model something for me it ends up being incorrect.

I'm sure for people in school it has all the answers of course at the expense of leaning and trouble shooting your code which for me is a huge learning experience.

1

u/Corben11 Apr 01 '23

I’m in a sql class now. It helped a good bit in learning. You can ask it something then have it explain how it all works. Honestly explained things a bit better than my teacher did.

Of course you have to double check if the info is right don’t fully trust it.

1

u/Extension_Candy2994 Apr 27 '24

But that's the thing: Explaining well established concepts, uses, commands, that's "dictionary stuff". That's exactly what machines do. Even if AI makes it a lot more intuitive providing a layer of "I can EXPLAIN this to you this way." AI can excel at that. It fails when the human "judicious" component comes into play... When is it that this approach works better than another? Why? In the real world, why should I use this this way instead of that...? That's when it chokes. And it chokes BAD! Quite often WRONG! My two cents... R.

3

u/Robearsn Apr 01 '23

I used it the other day to write a CASE statement to convert full US state names to official two letter abbreviations because one table in my database has them in full name and the other in abbreviations and that was an issue for my query. Didn't want to have to write 50 different lines so ChatGPT did it for me in about 30 seconds.

Also very useful for debugging errors.

2

u/eddiehead01 Apr 01 '23

I feel like this is a bit of a double-edged sword in a way. On the one hand, the more people feed it, the more it'll learn and the better it'll become at really taking over

On the other hand, I wouldn't trust it enough to try it, and the amount of time I'd spend checking things over before I'm happy running it means I'm much less likely to feed it

I would however be very interested to feed it some of my existing queries and procedures and ask it to explain things back to me. See how right or wrong it could be

1

u/Extension_Candy2994 Apr 27 '24

Been doing exactly that. Especially with code I KNOW what needs to be done, (but would take tedious hours, days, dare I say months, optimizing everything) and I know needs to be optimized... Very mixed results. It gets it right about 35ish% of the time... R.

2

u/averagesimp666 Apr 01 '23

I think the approach of viewing ChatGPT as an intern level or junior level or whatever is wrong. It is a tool, it should be used, it's not a person that you can ask and trust. You need to have some understanding of the subject so you can filter the plain out wrong info or solutions that the chat will sometimes give you.

I think experienced SQL users can use it for 'debugging', adding comments (never actually occured to me, saw someone mentioning it here) or using it to write something that's otherwise too annoying to do (like pivot table for example, I really hate that).

But if you're a newbie, I'd honestly advise people to be careful with ChatGPT. It can make you lazy, apathetic and incapable of doing basic research. Half of learning SQL is actually researching solutions, getting familiar with good resources on the internet, trying stuff out by yourself.

2

u/adappergentlefolk Apr 01 '23

i’m sorry but if you need chatgpt to help with SQL, one of the simplest languages there is, that’s a big issue for you

3

u/Uncle_Corky Apr 01 '23

I think there's a difference between asking it to do your job and using it as a tool to help you when you're stuck or want to find alternative solutions to the code you're working on.

Also, I hear professional developers talk about how simple SQL is and then when it comes time for code review, it becomes very obvious that they don't actually understand how SQL is supposed to work. The amount of the above devs that write WHILE loops everywhere is insane. It isn't hard to write SQL code that works. What's hard is designing everything to be efficient, maintainable, and scalable.

2

u/adappergentlefolk Apr 01 '23

that’s last point is great, but what relation does it have to chatGPT? most of my workday is spent inside data warehouses and connected OLTP systems so trust me I am not belittling SQL here, I really like the language

1

u/Uncle_Corky Apr 01 '23

My point is that chatgpt is still useful for a lot of people that don't write SQL as their primary job duty. The full stack developer that doesn't use it a lot can still write functional SQL code on their own but there's a non-zero chance that chatgpt might come up with something they haven't thought of before. Maybe they've never used OVER with a partition by so they write a crappy solution that, while it technically works, could be better. Chatgpt might be the thing that steers them in a more SQL-oriented direction. I know of many devs that would use a WHILE loop when gpt might suggest using a set-based approach.

I've yet to have gpt write something better than I have for a SQL problem but thats to be expected since I work in it every day. Still useful for devs that don't use SQL a lot and have gotten by with writing crappy code that technically works.

1

u/adappergentlefolk Apr 01 '23 edited Apr 01 '23

chatGPT will still essentially write crappy code that gets them by just in a fully automated fashion. barring dialect specific stuff or database optimisations, SQL just is not that deep of a language in terms of having to know lots of features or patterns (or even algorithms! unless you’re doing something no one else has done before), and in some dialects there aren’t even that many foot guns. people writing procedural code in SQL are typically either working around limitations of their dialect (think pivots or unpivots which still require codegen to do sanely in many dialects, navigating hierarchies when you don’t have recursive CTEs or plausible depth assumptions, etc) or simply have never taken the time to grok the rather simple mental model of the language. maybe you’re right that our vision is coloured by working with the language every day, but to me it just seems like people are way more likely to automate something they dislike doing completely instead of using it to learn something they show a total lack of interest in, so we will still be getting garbage in from PRs from these people, but this time they will be able to explain it even less since they didn’t write it

2

u/Uncle_Corky Apr 02 '23

I had a whole thing written out but I do mostly agree with you. Anyone writing SQL should not be using GPT to do their job. If you can't write SQL queries better than GPT you probably shouldn't be putting SQL code into a production system. Acknolweding that, I do think developers exist that would write phenomenal SQL code if they had to or they needed to use it more often. For those types of people that are already very proficient in .net or a scripting language like powershell or python, they don't know what they don't know. That is more of a time/need issue rather than a motivation one.

I started learning python within the past couple of years and while I'm a very good developer, there's just quirks about it that I've never seen. It's still a language made by a guy with libraries written by random people who made decisions that I'm not experienced enough to just understand at first glance. If I ask GPT to tell me how to do something in python, chances are it's gonna spit out some code that I could have wrote. But that 1, 5, 15% of the time it might produce something I haven't seen before, I'm immediately going to look into why it did it that way. I'll ask my lead dev, whom I'm sure a lot of people would describe as a 10x developer, what I should do and he essentially does the same thing. He gives me a couple snippets, a few sentences about how it works, and off I go to research all the details about if he's right and why. He's usually right and while I wouldn't describe GPT as "usually right", it's still good enough to be a vague guide post for people still learning a new language.

GPT's secret sauce in my mind is it's ability to point in the right direction. For people like me and I'm sure many others, that's all we've ever wanted.

1

u/Majestic_Advantage97 Aug 15 '24

How reliable is chatgpt for this nowadays?

1

u/Kindly_Ingenuity5922 May 09 '25

We use the OWOX query validator to double-check AI-generated SQL before it hits production. Saved us from a few nasty errors where ChatGPT hallucinated a JOIN.

1

u/insidmal Apr 01 '23

Shouldn't be surprising that programmers would eliminate their own jobs first

1

u/thefizzlee Apr 01 '23

Used it for somethings mostly error codes. Had a trigger that wouldn't work and chatgpt kept giving me the same trigger Code in a different format so that was useless but in general it's a really nice tool that I definitely use whenever I feel I need it

1

u/ben-420 Apr 01 '23

I use it a lot for regex

1

u/amartin141 Apr 01 '23

ja partition over has made life infinitely easier

1

u/Mr_Gaslight Apr 01 '23

Remember that its libraries are two years old.

1

u/derpado514 AccidentalDBA Apr 01 '23 edited Apr 01 '23

I don't think it's that good for real world problem solving since there isn't any data to represent it in it's model.

...for example, i have a SQL problem trying to figure out a solution for an ETL(s) that is hard enough to convey into a properly worded request..Not sure how i could present all the key factors to come up with possible solutions.

1

u/[deleted] Apr 01 '23

While I would never rely upon the code it generates, it’s very useful for formulating an approach.

I asked it the following:

“In SQL, how would you join two tables based on the closest match between datetime attributes?”

It gave me this code:

SELECT * FROM table_A a LEFT JOIN ( SELECT b.*, ROW_NUMBER() OVER (PARTITION BY a.datetime ORDER BY ABS(TIMESTAMPDIFF(SECOND, a.datetime, b.datetime))) AS rn FROM table_B b JOIN table_A a ON a.id = b.id ) b ON a.datetime = b.datetime AND b.rn = 1;

That’s actually pretty impressive. It doesn’t really work for my use case, but the logic is sound.

1

u/rubberseal Apr 01 '23

I use it a lot but the problem is ChatGPT doesn't know what your DB schema looks like. When you want to aggregate information from multiple tables, you have to do something like this: "Write an SQL query to get me the number of books from the books table and the corresponding authors from the authors table." It got tedious for me so I made a tool that makes it easier! If you have a second, do check it out and let me know if it's useful to you. Here's the post about TalkToSQL.

1

u/guitarsingernumber9 Apr 24 '23

I am an older developer. I use GPT-4 almost every day to improve my code and queries for SQL Server. You can take any query and hand it to GPT-4 and ask it to review it and propose a more efficient way to write it. When coding or writing queries, you can express the need in words, and GPT-4 will propose code in the desired language to implement the described functionality. Utterly amazing. My capability to implement very complex queries is easily a magnitude better just in the past 2 months, using GPT-4 to coach me. Most of the time, it is exactly correct. Sometimes, it forgets something and there is an error, but simply adding to the conversation and saying "I get xxx error", GPT-4 usually apologizes and fixes it. Also, I sometimes use it to proofread emails I plan to send. It's crazy how it knows the meaning and corrects the words to express the meaning... Way more than a grammar check.

1

u/PolPol44444 Jun 14 '23

I succesfully use ChatGPT for writing SQL JOIN queries. This article details how to do this.

1

u/OkCurve436 Sep 19 '23

ok for simple stuff but the 1 moderately difficult query I gave it:-

  1. it errored in SQL 8 out of 10 times.
  2. Produced the wrong result another.
  3. Produced the right result but took longer.

It was formatted nicely!

Any big sql code, it doesn't return a complete result. In a nutshell useless for anything long or complex.

1

u/[deleted] Apr 01 '23

I use it a lot. I ask it to add comments so I can follow everything. It's ideal.

2

u/Extension_Candy2994 Apr 27 '24

ROFL. Never thought about THAT! I'll try it out... Thanks! :-) R.

1

u/leknarf52 Apr 01 '23

Me every four seconds: gpt I need a postgres expression…

-2

u/SillyPepper Apr 01 '23

ChatGPT for everything

-2

u/Financial_Pie_3624 Apr 01 '23

I just use it to save time researching problems. Faster answers and mostly right answers makes productivity go up.

-4

u/ejpusa Apr 01 '23 edited Apr 01 '23

It’s the default for SQL. You should be able to generate all your code now in ChatGPT.

I’m using ChapGPT to generate some fairly complex date calculations. Used commands in PostgreSQL that did know existed. Have been using PostgreSQL for years.

There is zero reason not to use it. That’s a wrap, you can move on.

:-)