MS Access Query Stalling - ms-access

Fairly new to writing queries in access and hoping that I can get some help with the logic to determine why its stalling at 99%.
Overview: The query I am running is based on a table (Test1) which has two columns, Accounts & Payments, and has about 75k+ rows. Account #'s can be repeated more than once (Duplicates), or displayed one-time (Distinct) -- as well as the Payments. [Table example below]
table.redTable {
border: 2px solid #000000;
background-color: #FFFFFF;
width: 100%;
text-align: center;
border-collapse: collapse;
}
table.redTable td, table.redTable th {
border: 1px solid #AAAAAA;
padding: 3px 2px;
}
table.redTable tbody td {
font-size: 13px;
}
table.redTable th:thead {
background: #FFFFFF;
}
table.redTable thead th {
font-size: 19px;
font-weight: bold;
color: #FFFFFF;
background: #A4A3A3;
text-align: center;
border-left: 2px solid #FFFFFF;
border: 3px solid #000000;
}
table.redTable tfoot {
font-size: 13px;
font-weight: bold;
color: #FFFFFF;
background: #A40808;
}
table.redTable tfoot td {
font-size: 1px;
box-sizing: 0.1px;
background: #FFFFFF;
border: 1px solid #A53426;
}
table.redTable tr:nth-child(1) {
background: #FFFFFF;
border: 3px solid #A53426;
}
table.redTable tr:nth-child(2) {
background: #FFFFFF;
border: 3px solid #A53426;
}
table.redTable tr:nth-child(3) {
background: #FFFFFF;
border: 3px solid #A53426;
}
table.redTable tr:nth-child(4) {
background: #FFFFFF;
border: 3px solid #A53426;
}
table.redTable tr:nth-child(5) {
background: #3C983F;
border: 1px solid #000000;
}
table.redTable tr:nth-child(6) {
background: #3C983F;
}
table.redTable tr:nth-child(7) {
background: #FFFFFF;
border: 3px solid #A53426;
}
<table class="redTable">
<thead>
<tr>
<th>Accounts</th>
<th>Payments</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2"> </td>
</tr>
</tbody>
<tbody>
<tr>
<td>42229</td>
<td>$40.00</td>
</tr>
<tr>
<td>42229</td>
<td>$40.00</td>
</tr>
<tr>
<td>55908</td>
<td>$25.00</td>
</tr>
<tr>
<td>55908</td>
<td>$25.00</td>
</tr>
<tr>
<td>55908</td>
<td>$25.00</td>
</tr>
<tr>
<td>55908</td>
<td>$5.00</td>
</tr>
<tr>
<td>103848</td>
<td>$35.00</td>
</tr>
</tbody>
</table>
Query Goal: The outcome of the query is to display only Duplicate Account Numbers where the Payment value is different. Ex. Account 12345 is listed 3 times with Payment value of $20, $10, and $10 the query should list Account 12345 twice with a listed Payment of $20 and $10.
Issue: When attempting to run the query it gets to 99% and stalls out/never completes. Below is a copy of logic I wrote -- any assistance/tips would be greatly appreciated.
SELECT DISTINCT j.Accounts, j.Payments
FROM Test1 AS j
INNER JOIN
(SELECT Accounts, count(*) AS diffPayments FROM (
SELECT DISTINCT
Accounts,
Payments
FROM
Test1
WHERE
Accounts in (
select Accounts from (
select Accounts, count(*) as [Count] from Test1 group by Accounts
) x where x.Count > 1
)
) t GROUP BY Accounts
) AS z ON j.Accounts = z.Accounts
WHERE (((z.diffPayments)>1))
;

Consider:
SELECT Accounts, Payments FROM Test1 WHERE Accounts IN(
SELECT Accounts FROM (
SELECT Accounts, Payments FROM Test1 GROUP BY Accounts, Payments)
GROUP BY Accounts
HAVING Count(*)>1)
GROUP BY Accounts, Payments;
Or:
SELECT DISTINCT Accounts, Payments FROM Test1 WHERE Accounts IN(
SELECT Accounts FROM (
SELECT Accounts, Payments FROM Test1 GROUP BY Accounts, Payments)
GROUP BY Accounts
HAVING Count(*)>1);
Or:
SELECT Test1.Accounts, Payments FROM Test1 INNER JOIN (
SELECT Accounts FROM (
SELECT Accounts, Payments FROM Test1 GROUP BY Accounts, Payments)
GROUP BY Accounts
HAVING Count(*)>1) AS Q1
ON Test1.Accounts=Q1.Accounts
GROUP BY Test1.Accounts, Payments;
Or
SELECT DISTINCT Test1.Accounts, Payments FROM Test1 INNER JOIN (
SELECT Accounts FROM (
SELECT Accounts, Payments FROM Test1 GROUP BY Accounts, Payments)
GROUP BY Accounts
HAVING Count(*)>1) AS Q1
ON Test1.Accounts=Q1.Accounts;

Related

Add bottom border, after adding inner borders, to Table CSS

Hello I want to add borders inside a table, and in the bottom of the table. With what i found, i was able to add the inner borders, however, i am getting trouble in adding also the bottom border. How can i do it ?
My table
<table class="table">
<thead>
<tr>
<th>Produto</th>
<th>Quantidade</th>
<th>Valor</th>
</tr>
</thead>
<tbody>
<tr v-for="c in compras">
<td>{{c.nome}}</td>
<td>{{c.qtd}}</td>
<td>{{c.valor}}</td>
</tr>
</tbody>
</table>
And the Css i have, that managed to fill the inner borders
table {
border-collapse: collapse;
border-style: hidden;
}
table td, table th {
border: 1px solid black;
border-bottom: 1px solid black;
}
Thank You
table {
border: 1px solid black;
border-bottom: 1px solid black;
}
exactly the same which you used for the inners

HTML table first column much larger than the second column

So I am creating a table in html using javascript. However, anytime I create the table, the first column is much larger than the second column, while the second column is extremely compressed.
I am trying to get the first column to be compressed and the second column to be the larger one, but for some reason it doesn't want to work.
let rankings2 = [];
function generateTableHead(table, data) {
let thead = table.createTHead();
let row = thead.insertRow();
for (let key of data) {
let th = document.createElement("th");
let text = document.createTextNode(key);
th.appendChild(text);
row.appendChild(th);
th.style.textAlign='center';
}
}
function generateTable(table, data){
for (let element of data) {
let row = table.insertRow();
for (key in element) {
let cell = row.insertCell();
let text = document.createTextNode(element[key]);
cell.appendChild(text);
cell.style.textAlign='center';
}
}
}
let HotSeat = [{pos: "1", name:"Ben Shapiro's Wife"},
{pos: "2", name: "Illegal Bookies"},
{pos: "3", name: "76ers"},
{pos: "4", name: "The Post Office",},
{pos: "5", name: "New Orleans"}];
let table2 = document.getElementById("HotSeatTable");
let data2 = Object.keys(HotSeat[0]);
generateTableHead(table2,data2);
generateTable(table2,HotSeat);
window.history.forward(1);
#HotSeat {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
margin: 0 auto;
width: 50%;
box-shadow: 0 4px 6px 0 hsla(0, 0%, 0%, 0.2);
}
#HotSeat td,
#HotSeat th {
border: 1px solid #ddd;
text-align: left;
width: 100%;
padding: 20px;
}
#HotSeat tr:nth-child(even) {
background-color: #f2f2f2;
}
#HotSeat tr:hover {
background-color: #ddd;
}
#HotSeat th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
width: left;
background-color: red;
color: white;
}
<div id="HotSeat">
<table id="HotSeatTable"></table>
</div>
here is what the table looks like when I dont have width: 100% in td,th
Remove width off the td selector. This is causing your columns to look skewed.
Then add width: 100% to get the table to fit the width of the container.
Additionally, I am not sure what you are trying to do with width: left property, so I would remove it. Same with the text-align: left in your style sheet, you set text-align: center dynamically in your JS, rendering left align useless unless you really want them left aligned.
#HotSeat {
border-collapse: collapse;
margin: 0 auto;
width: 50%;
}
#HotSeatTable {
width: 100%;
text-align: center;
}
#HotSeat td,
#HotSeat th {
border: 1px solid #ddd;
padding: 20px;
}
#HotSeat th {
padding-top: 12px;
padding-bottom: 12px;
background-color: red;
color: white;
}
<div id="HotSeat">
<table id="HotSeatTable">
<table id="HotSeatTable">
<tr>
<th>Pos</th>
<th>Name</th>
</tr>
<tr>
<td>1</td>
<td>Ben Shapiro's Wife</td>
</tr>
<tr>
<td>2</td>
<td>Illegal Bookies</td>
</tr>
<tr>
<td>3</td>
<td>76ers</td>
</tr>
<tr>
<td>4</td>
<td>The Post Office</td>
</tr>
<tr>
<td>5</td>
<td>New Orleans</td>
</tr>
</table>
</div>

How can i select elements right after a :first-child in CSS?

Im trying to select a section on a table by making its border thicker on a selected area, so I need to change the border on specifics cells to get something like this.
this is my best try for the upper one.
every selected cell has a "selected" class, and if there is a selected cell, the row has a selected class too. I hope you get it ;)
.table tr.selected:first-child td.selected{
border-top-width:5px;
border-top-color:#000;
}
is it possible?
If you are not restricted with these specific class names, you can add a custom class to cells of the last selected row. If you cannot modify the HTML, you can try to add the custom classes with JavaScript.
var selectedRows = document.querySelectorAll('tr.selected');
selectedRows[selectedRows.length-1].classList.add('last-selected-row');
table{
border-collapse: collapse;
}
table tr td{
border: 1px solid #e2e4e8;
padding: 10px;
}
table td.selected{
background-color: #cae5cd;
}
table tr.selected td.selected:first-child{
border-left: 3px solid black;
border-right: none;
}
table tr.selected td.selected:last-child{
border-right: 3px solid black;
border-left: none;
}
table tr.selected td.selected + td:not(.selected){
border-left: 3px solid black;
}
table tr:not(.selected) + tr.selected td.selected{
border-top: 3px solid black;
border-bottom: 1px solid #e2e4e8;
}
table tr.last-selected-row td.selected{
border-bottom: 3px solid black;
}
<table>
<tr>
<td>far east</td>
<td></td>
<td>USD</td>
</tr>
<tr>
<td>pol</td>
<td>pod</td>
<td>USD</td>
</tr>
<tr class="selected">
<td class="selected">VALENCIA MADRID</td>
<td class="selected">BRISBANE</td>
<td>USD</td>
</tr>
<tr class="selected">
<td class="selected">VALENCIA MADRID</td>
<td class="selected">Melbourne</td>
<td>USD</td>
</tr>
<tr class="selected">
<td class="selected">VALENCIA MADRID</td>
<td class="selected">SYDNEY</td>
<td>USD</td>
</tr>
<tr>
<td>VALENCIA MADRID</td>
<td>Chongoing</td>
<td>USD</td>
</tr>
</table>
The padding and the border styles I have added in the snippet are just for demo purpose.

HTML email <tr> tag border formatting issue

I am trying to format the table to have rows separated by lines.Even tried using inline styles but nothing worked. Am I missing anything here?
Expected output :
Output I am getting :
Here is the perl code that I am using to generate the HTML for the email :
my $section_html = '';
$section_html.=qq(<table><tr style="border : 1px solid black;"><td>Hello1</td><td>Hello2</td></tr><tr style="border : 1px solid black;"><td>Hello3</td><td>Hello4</td></tr></table>);
my $email_html = <<EOF;
<html><head><style type="text/css">
body, td, th, strong { font-family: Verdana; font-size: 11px; }
table {
border:none;
border-collapse: collapse;
text-align:center;
}
table td {
border-left: 1px solid #000;
border-right: 1px solid #000;
}
table th {
border-left: 1px solid #000;
border-right: 1px solid #000;
}
table td:first-child {
border-left: none;
text-align:left;
}
table td:last-child {
border-right: none;
}
table tr{
border-top : 1px solid #000;
}
table tr{
border-top : 1px solid black;
}
</style></head>
<body bgcolor="#ffffff">
<span style="font-size: 20px">Report Header</span>$section_html</body></html>
EOF
# Write to file
open(FILE, ">/var/weekly_report/"."report"."_"."testing".".html") or die "Unable to open file for writing: $!\n";
print FILE $email_html;
close(FILE);
# Email weekly report
my $msg = MIME::Lite->new(
To => 'XXXX#somedomain.com',
Subject => 'Report subject',
Type => 'text/html',
Data => $email_html);
$msg->send();
This is going old school. Try this method as well. The difference from Ted's answer is, you have the whole table the same color and in his answer you can choose the border color for different td's or th's.
<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#000000">
<tbody>
<tr>
<td width="50%" bgcolor="#ffffff">Hello1</td>
<td width="50%" bgcolor="#ffffff">Hello1</td>
</tr>
<tr>
<td bgcolor="#ffffff">Hello1</td>
<td bgcolor="#ffffff">Hello1</td>
</tr>
</tbody>
</table>
Some email clients (and maybe browsers) don't allow us to directly style the <tr> tag. It's also safer to avoid relying on :first-child and :last-child pseudo selectors, as they are not well supported in email.
However you we can achieve your desired effect by styling the <table> and <td> tags:
table {
border-top: 1px solid #000;
border-right: 1px solid #000;
}
table td,
table th {
border-left: 1px solid #000;
border-bottom: 1px solid #000;
}
You can also have absolute control by inlining all CSS, which is still a good idea in HTML email.

How to move items left and right in an html table using css? -

I have 6 <td>s in my <tr>s and I want the last 3 in each row to all be closer together. How can I move them?
Here is my html:
<p> Test.com Funtown <div>Click Here</div> </p>
<table>
<tbody>
<tr>
<td class="statusRunning">R</td>
<td>My First Try</td>
<td>100 / 250 plays</td>
<td>Players</td>
<td>Duplicate</td>
<td>Archive</td>
</tr>
<tr>
<td class="statusQueued">1</td>
<td>The best try</td>
<td>0 / 250 plays</td>
<td>Players</td>
<td>Duplicate</td>
<td>Archive</td>
</tr>
<tr>
<td class="statusIncomplete"> </td>
<td>Could be better</td>
<td>0 / 50 plays</td>
<td>Players</td>
<td>Duplicate</td>
<td>Archive</td>
</tr>
</tbody>
</table>
Here is my css:
p {
}
div a {
}
table {
padding: 0;
margin: 10;
border-left: none;
border-right: none;
text-align:right;
border-collapse:separate;
border-spacing: 0 2px;
}
table tr {background:#fff;}
table tr:hover {background:#EBF7FC;}
table tr td {padding:6px 8px;}
table tr td:first-child {border-left: 3px solid #fff;}
table tr td:last-child {border-right:3px solid #fff;}
table tr:hover td:first-child {border-left: 3px solid #4EB2E2;}
table tr:hover td:last-child {border-right:3px solid #4EB2E2;}
table tr td:nth-child(1){
color:#fff;
width: 33px;
padding: 5px 0;
text-align: center;
}
.statusRunning {
background-color: #5AD427;
}
.statusQueued {
background-color: #A4E786;
}
.statusIncomplete {
background-color: #FFCC00;
}
table tr td:nth-child(2){
text-align:left;
}
I would just put them all into the same <td> and add margin/padding to the <a> element inside the <td>then you could add whatever number of links you want in there.
here is a fiddle below.
http://jsfiddle.net/D7sTY/
Html
<tr>
<td class="statusRunning">R</td>
<td>My First Try</td>
<td>100 / 250 plays</td>
<td class="tightcell">PlayersDuplicateArchive</td>
</tr>
CSS
.tightcell a
{
margin: 0 2px;
}
Target them separately using CSS and remove/decrease the padding.
table tr td:nth-child(4), table tr td:nth-child(5), table tr td:nth-child(6){
padding:0;
}
http://jsfiddle.net/G4Dw5/2/
I completely removed the padding on them, you might want to add a few pixels though.
nth-child(n+4) like so (fiddle):
td:nth-child(n+4){
padding: 0;
}
Here's a preview:
Set id atribute of HTML control to the css class included in your .css file
and add following code in your .css file
<HTMLControl id="id">
#id{
margin-left: 20px;
margin-top: 15px;
margin-bottom: 15px;
enter code here}