LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-07-2023, 08:36 AM   #16
picklehead
Member
 
Registered: Jun 2018
Posts: 56

Original Poster
Rep: Reputation: Disabled

Anyway, this is a tech forum not an advice or agony aunt column.
 
Old 02-07-2023, 08:39 AM   #17
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 19,880

Rep: Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734
Quote:
Originally Posted by picklehead View Post
I agree, but this isn't a DBA or SQL job. It's a Linux Team job and there's only this one SQL question.
I will get an interview if I can answer this banana skin question on the technical assessment.

All my other skills Linux, SNMP, Networking, bash scripting, virtualisation are fine. It's just this one question that some guy recommend they ask and it's completely irrelevant to the job but they've lost loads of candidates because of it. Just because of pettiness.
And it is completely pointless. You want to say you know the answer? Or what? And why? I can give you the answer but you can't even check if that was correct or not...
 
Old 02-07-2023, 08:44 AM   #18
picklehead
Member
 
Registered: Jun 2018
Posts: 56

Original Poster
Rep: Reputation: Disabled
OK so I have the second part

Now it's

SELECT FirstName, LastName FROM Employees
WHERE FirstName LIKE '%e%' AND LENGTH(LastName) > 5;


But that satisfies the conditions and returns the firstnames and lastname (I found a test database with a run SQL function)

But I have no clue how to count the number of rows returned. There are 7 in the table that I found.
 
Old 02-07-2023, 08:50 AM   #19
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,129

Rep: Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213
Quote:
Originally Posted by picklehead View Post
I agree, but this isn't a DBA or SQL job. It's a Linux Team job and there's only this one SQL question.
I will get an interview if I can answer this banana skin question on the technical assessment.

All my other skills Linux, SNMP, Networking, bash scripting, virtualisation are fine. It's just this one question that some guy recommend they ask and it's completely irrelevant to the job but they've lost loads of candidates because of it. Just because of pettiness.
It is (should be) perfectly ok to say "I don't know" - depending on the question, it may be wise to follow up with "but if I needed to, I would XYZ".

Some interviewers will deliberately ask irrelevant questions to see how candidates respond.

Given your second paragraph... if they're that petty in an interview, maybe it's a sign - are you sure it's a place you want to work at?


Quote:
Originally Posted by picklehead View Post
But I have no clue how to count the number of rows returned.
Put what you just typed into a search engine, prefixed by sql and you will get the answer!

 
1 members found this post helpful.
Old 02-07-2023, 08:56 AM   #20
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,168
Blog Entries: 4

Rep: Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705
select count(*) from ... (response #18)

However, I will also be one to say: if you are looking for the answer to a technical-interview question, "asking for the right answer on a forum" is not the right way to go about it. There are an abundance of SQL-tutorial web sites out there, and some of them even allow you to type in queries to "try them out for yourself."

SQL "select" queries are quite simple:
  • "SELECT" what? – fields or function results
  • "FROM" somewhere – could be a single table or a "JOIN" between multiple tables based on common field values. (There are several types of JOINs available.)
  • "WHERE" conditions are met on the rows.
  • (Optional) "GROUP BY" fields to produce summary values (count, average, etc.) for all unique combinations of those fields instead of the rows themselves.
  • (Optional) "HAVING" if you want to limit which grouped rows are returned
  • "ORDER BY" to sort the results.

Unlike other types of databases, SQL will attempt to give you your answer no matter how the database is organized or indexed, always finding on its own the most-efficient way to do that. In one step, it takes your query, figures out the best way to do it, and does it. (IBM's "SEQUEL" system was completely revolutionary, at the time ...)

While SQL is "mostly standardized," there are "dialect" differences between them. Most will support the same basic "select" syntax although there may be function-name differences. Some provide considerably more capability, such as constructing "pivot tables." Some, such as SQLite, do not support certain usually-standard things because of the particular nature of their implementation.

But: "learning to program is like learning to swim – you have to get in the water, shallow end first." You have to "try ... ... try again." Yes, it is frustrating, especially at first. Until the turns on.

If you ask someone else for the answer, you're not learning to swim. You're just asking for a life-ring to be thrown to you by someone who did get into the same pool and "learn how."

The real task of "learning SQL" is not mastering the relatively-simple syntax of the statements. The real task is to take the problem description, and knowledge of the database, to decide what an appropriate SQL query should be. There may be more than one answer.

Last edited by sundialsvcs; 02-09-2023 at 10:24 AM.
 
1 members found this post helpful.
Old 02-07-2023, 09:30 PM   #21
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,695

Rep: Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025
Or ask an AI: https://you.com/search?q=I+need+to+f...ue&tbm=youchat
 
Old 02-07-2023, 09:50 PM   #22
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 18,167

Rep: Reputation: 2680Reputation: 2680Reputation: 2680Reputation: 2680Reputation: 2680Reputation: 2680Reputation: 2680Reputation: 2680Reputation: 2680Reputation: 2680Reputation: 2680
SQL systems are endemic these days.
If you want to be a Linux admin (not a network eng), then a basic knowledge is expected.
 
Old 02-07-2023, 10:06 PM   #23
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,168
Blog Entries: 4

Rep: Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705
For those seriously interested, let me please emphasize:

"The real task of "learning SQL" is not mastering the relatively-simple syntax of the statements. The real task is to take the [abstract] problem description, and knowledge of the database, to decide what an appropriate SQL query should be."

Elementary mastery of "SQL" is only the first step – akin to "mastery" of the circular saw and the hammer in the construction trades. You must master these skills before you can move on, but the mere mastery of these skills does not mean that you have moved on.

For example: "the person who you just hired to build a deck" did not gain his qualifications for doing so merely because he knew how to use a [tool]." Instead, he gained his position by knowing how to apprise the situation of "building your deck," and then to successfully execute the task of actually building it – of course using [tools].

Last edited by sundialsvcs; 02-07-2023 at 10:14 PM.
 
Old 02-08-2023, 11:13 AM   #24
picklehead
Member
 
Registered: Jun 2018
Posts: 56

Original Poster
Rep: Reputation: Disabled
Got it

SELECT COUNT(*) FROM Customers
WHERE CustomerName LIKE '%m%'AND LENGTH(Country) < 4;


Number of records where customer has "m" ib the name and country has less than 4 chars.
 
Old 02-09-2023, 02:23 AM   #25
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 19,880

Rep: Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734Reputation: 6734
Ok, that is actually good news. And now?
If you think your problem is solved please mark the thread as solved.
 
Old 02-09-2023, 10:30 AM   #26
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,168
Blog Entries: 4

Rep: Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705Reputation: 3705
Well, this actually-trivial question has obviously been "solved," but the real point of the thread is that you must learn how to solve these things for yourself. Because, "on the job," you are constantly going to be required to do this. Every company's databases – for historical reasons or otherwise – will be different. In order to be technically competent, you must understand the tools that are available in the [SQL ...] databases that you are using. And, if your software uses an "SQL abstraction layer," you must understand this also.

At the end of every day, your job is to come up with "the right answer."

This requires time, and most of all it requires practice. "Just like swimming," it is actually not that very complicated. But, you must get into the pool. Fortunately for all of us, other people have constructed "practice web sites" which allow you to experiment without first constructing a database of your own or setting up a server.

FYI: "It is a HUGE mistake to 'bluff your way into a job.'" Far better to candidly admit what you do not yet know, and to profess your eagerness to learn it. (After all, "that is how you learn ...") They just might hire you anyway.

Speaking as a "hiring manager" myself, a "hiring manager" above all does not want to be deceived. There are plenty of available resources to "bring a new team member 'up to speed,'" as long as one actually and truthfully realizes what this person does and does not yet(!) know. "Nobody knows everything, even if they think that they do." Better to understate what you think that you can do, and let them be pleasantly surprised.

Looking back, I can certainly say that I tended to hire people who were less certain of their abilities, because I felt that they were being honest with me. If the candidate appeared to be "too good to be true," I trusted my gut.

"Never make a promise to anyone that you are not certain that you can keep!" It is perfectly okay to tell someone: "I'm not sure, but I'll try, and I'll be the first one to let you know." "Honesty is the best policy.™"

Last edited by sundialsvcs; 02-09-2023 at 10:46 AM.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Moving with SQL Server to Linux? Move from SQL Server to MySQL as well! LXer Syndicated Linux News 0 11-28-2016 02:02 PM
[SOLVED] Graphics acceleration works well for root, not so well for user lipk Slackware 3 03-28-2013 04:16 AM
SQL noob question: can SQL effectively handle a 2D matrix? JoeyAdams Programming 2 03-17-2008 01:10 AM
SQL: old sql dump not loading into new db BrianK Linux - Software 1 07-25-2006 11:55 PM
Well well well..what do we have here? DaBlade Linux - News 4 10-03-2005 10:07 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration