Formatting results

Creating tables and queries
Post Reply
imagrump
Posts: 26
Joined: Mon Sep 28, 2015 11:22 pm

Formatting results

Post by imagrump »

I have searched and cannot find a solution to my problem. I am new to databases so that is not unusual. I query my database for the last 2 years data on certain names (usually 60 to 100). All I want is the last 6 lines of data. The data returned will be from o to 35 or so lines. Is it possible to have just 6 lines for each entrant returned? Is it also possible to format an additional 2 lines (blank ) for each? Instead of 6 or fewer lines, there would be 6 or 8 for each name.
I realize that this probably involves learning some language for the query. First, I need to know if it can be done....if it can, then I need to find out how; if not; then I can quit looking.
THANKS
Open Office 4.1.1 on
Windows 7 Home
F3K Total
Volunteer
Posts: 1038
Joined: Fri Dec 16, 2011 8:20 pm

Re: formatting results

Post by F3K Total »

Hello,
if i got you right, yes it's possible. See Query in attached example.
But IMPOV, the two empty lines do not make sense, should be implemented in a report from VIEW1.

R
Attachments
SIX_LINES.odb
(71.33 KiB) Downloaded 205 times
  • MMove 1.0.6
  • Extension for easy, exact positioning of shapes, pictures, controls, frames ...
  • my current system
  • Windows 10 AOO, LOLinux Mint AOO, LO
imagrump
Posts: 26
Joined: Mon Sep 28, 2015 11:22 pm

Re: Formatting results

Post by imagrump »

Thank you for the response...from what I can see, it appears to do what I want. The problem is that I do not know how to do this myself with my DB. I run a SELECT QUERY and get the results but have no way of limiting it to 6 rows per entrant to work with.
Can you provide a bit more info for someone just beginning databases? I am isolated and unable to learn other than by reading tutorials and other technical works. Sometimes, what is clear to you because of your background does not make sense to one hearing this for the first time without much background in the subject.
I learn fairly well but assistance is always welcome in something new and so different.
THANKS, again.
Open Office 4.1.1 on
Windows 7 Home
F3K Total
Volunteer
Posts: 1038
Joined: Fri Dec 16, 2011 8:20 pm

Re: Formatting results

Post by F3K Total »

Hello imagrump,
sorry, but it's not possible to teach you SQL here in this forum. To see the main-code, rightcklick VIEW1 -> Edit in SQL View...then you should see this select-statement:

Code: Select all

SELECT
    COUNT (*) AS "NO",
    "X"."SN",
    "X"."FN",
    "X"."VALUE",
    "X"."TS"
FROM
    "DATA" AS "X"
JOIN
    "DATA" AS "Y"
ON
    "X"."TS" <= "Y"."TS"
AND
    "X"."SN" = "Y"."SN"
AND
    "X"."FN" = "Y"."FN"
GROUP BY
    "SN",
    "FN",
    "VALUE",
    "TS"
HAVING
    COUNT (*) < 7
ORDER BY
    "SN","FN"
Here you'll find several links to the documentation of the OpenOffice buildin database engine HSQL1.8.10, which is old. And at Wikipedia you can find informations about queries too.
Maybe an other user is so kind to give you some better links to SQL tutorials, i don't know them in english language.
R
  • MMove 1.0.6
  • Extension for easy, exact positioning of shapes, pictures, controls, frames ...
  • my current system
  • Windows 10 AOO, LOLinux Mint AOO, LO
UnklDonald418
Volunteer
Posts: 1546
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Formatting results

Post by UnklDonald418 »

There are some websites that offer online SQL tutorials such as:
http://www.sqlcourse.com/
http://www.w3schools.com/sql/default.asp
From what you learn there you should be able to understand the query F3K Total presented and apply it to your situation.
One thing to note is that he made use of a View which is a hybrid Table/Query object.
A good tutorial for learning to use Base also has a little discussion of Views
https://wiki.documentfoundation.org/ima ... torial.pdf
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
imagrump
Posts: 26
Joined: Mon Sep 28, 2015 11:22 pm

Re: Formatting results

Post by imagrump »

I will learn SQL as a last resort. I had hoped that the standard query methods would solve my problem, but that does not seem to be the case. I do thank you for the links and I may have to use them. If limiting by standard methods does not work, then I will have to take the next step which is SQL.
I find it hard to believe that limiting the results from a select query is not easily available. Surely, I cannot be the only one who does not wany 3,00 lines when 300 to 400 would accomplish the same thing. Practically anyone doing queries for history lines wants a limitation in lines returned. I would think that any sports history database would use this.
Anyway, THANKS
Open Office 4.1.1 on
Windows 7 Home
Post Reply