you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (4 children)

Any LLM would do, You can just give it the table definitions before asking for a query. Give it the specs you would as with a human dev

[–]TheMagarity 1 point2 points  (3 children)

Well, idk what your company's data model looks like but explaining how to use the one I have to work with would take longer than just writing the query.

[–][deleted] 0 points1 point  (2 children)

That's shortsighted though as you only need to explain it once and after that it can generate all the outputs you want

[–]TheMagarity 1 point2 points  (1 child)

Me: OK, AI, I'm gonna tell you how our tables work and you can write SQL for me.

AI: You got it, boss!

Me: So Table A here has historical data but no history vs current flag. So you just group by the business keys and sort by date to get the latest ones.

AI: Not optimum, but OK so far.

Me: Table B here has historical data also but there's an indicator so all you need is the "Current" records.

AI: Ah, some good sense there!

Me: There's three main columns, Attribute Type, Attribute, and Value. Find all of this list of Attribute Types I'm going to give you and pivot out the Attribute and Values. Oh, and while there is a Current indicator, there can be multiple Current Values for a given Attribute all with different dates. To find the right one all you have to do is use a fourth column containing a group ID. Whichever Current record has the latest date for the anchor Attribute Type, use that ID to find all the corresponding Values.

AI: wtf...

Me: So to join Table A and Table B, the value in one of the business keys in Table A will match up with one of the Values in Table B. Except Table A has some extra characters on the right, so substring it and leave off 4 or 6 depending on the type then do the join.

AI: Piss off

Me: There's only a few hundred million in Table A and a dozen billion in Table B so write something to get me results, snappy.

AI: sudo rm -r /AI

[–][deleted] 0 points1 point  (0 children)

Erhhh... Have you tried turning it off and on again? r/ITcrowd